|
14 | 14 |
|
15 | 15 | from test import support
|
16 | 16 | from test.support import import_helper
|
| 17 | +from test.support.script_helper import assert_python_ok |
17 | 18 |
|
18 | 19 | py_uuid = import_helper.import_fresh_module('uuid', blocked=['_uuid'])
|
19 | 20 | c_uuid = import_helper.import_fresh_module('uuid', fresh=['_uuid'])
|
@@ -1217,10 +1218,37 @@ def test_cli_uuid5_ouputted_with_valid_namespace_and_name(self):
|
1217 | 1218 | class TestUUIDWithoutExtModule(BaseTestUUID, unittest.TestCase):
|
1218 | 1219 | uuid = py_uuid
|
1219 | 1220 |
|
| 1221 | + |
1220 | 1222 | @unittest.skipUnless(c_uuid, 'requires the C _uuid module')
|
1221 | 1223 | class TestUUIDWithExtModule(BaseTestUUID, unittest.TestCase):
|
1222 | 1224 | uuid = c_uuid
|
1223 | 1225 |
|
| 1226 | + def check_has_stable_libuuid_extractable_node(self): |
| 1227 | + if not self.uuid._has_stable_extractable_node: |
| 1228 | + self.skipTest("
D270
libuuid cannot deduce MAC address") |
| 1229 | + |
| 1230 | + @unittest.skipUnless(os.name == 'posix', 'POSIX only') |
| 1231 | + def test_unix_getnode_from_libuuid(self): |
| 1232 | + self.check_has_stable_libuuid_extractable_node() |
| 1233 | + script = 'import uuid; print(uuid._unix_getnode())' |
| 1234 | + _, n_a, _ = assert_python_ok('-c', script) |
| 1235 | + _, n_b, _ = assert_python_ok('-c', script) |
| 1236 | + n_a, n_b = n_a.decode().strip(), n_b.decode().strip() |
| 1237 | + self.assertTrue(n_a.isdigit()) |
| 1238 | + self.assertTrue(n_b.isdigit()) |
| 1239 | + self.assertEqual(n_a, n_b) |
| 1240 | + |
| 1241 | + @unittest.skipUnless(os.name == 'nt', 'Windows only') |
| 1242 | + def test_windows_getnode_from_libuuid(self): |
| 1243 | + self.check_has_stable_libuuid_extractable_node() |
| 1244 | + script = 'import uuid; print(uuid._windll_getnode())' |
| 1245 | + _, n_a, _ = assert_python_ok('-c', script) |
| 1246 | + _, n_b, _ = assert_python_ok('-c', script) |
| 1247 | + n_a, n_b = n_a.decode().strip(), n_b.decode().strip() |
| 1248 | + self.assertTrue(n_a.isdigit()) |
| 1249 | + self.assertTrue(n_b.isdigit()) |
| 1250 | + self.assertEqual(n_a, n_b) |
| 1251 | + |
1224 | 1252 |
|
1225 | 1253 | class BaseTestInternals:
|
1226 | 1254 | _uuid = py_uuid
|
|
0 commit comments