8000 add tests · python/cpython@7a77509 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a77509

Browse files
committed
add tests
1 parent 6083e97 commit 7a77509

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Lib/test/test_uuid.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from test import support
1616
from test.support import import_helper
17+
from test.support.script_helper import assert_python_ok
1718

1819
py_uuid = import_helper.import_fresh_module('uuid', blocked=['_uuid'])
1920
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):
12171218
class TestUUIDWithoutExtModule(BaseTestUUID, unittest.TestCase):
12181219
uuid = py_uuid
12191220

1221+
12201222
@unittest.skipUnless(c_uuid, 'requires the C _uuid module')
12211223
class TestUUIDWithExtModule(BaseTestUUID, unittest.TestCase):
12221224
uuid = c_uuid
12231225

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+
12241252

12251253
class BaseTestInternals:
12261254
_uuid = py_uuid

0 commit comments

Comments
 (0)
0