|
1 | 1 | import unittest
|
2 | 2 | from test import support
|
3 | 3 | from test.support import import_helper
|
| 4 | +from test.support.script_helper import assert_python_ok |
4 | 5 | import builtins
|
5 | 6 | import contextlib
|
6 | 7 | import copy
|
@@ -32,8 +33,7 @@ def get_command_stdout(command, args):
|
32 | 33 | class BaseTestUUID:
|
33 | 34 | uuid = None
|
34 | 35 |
|
35 |
| - # TODO: RUSTPYTHON |
36 |
| - @unittest.expectedFailure |
| 36 | + @unittest.expectedFailure # TODO: RUSTPYTHON |
37 | 37 | def test_safe_uuid_enum(self):
|
38 | 38 | class CheckedSafeUUID(enum.Enum):
|
39 | 39 | safe = 0
|
@@ -775,10 +775,37 @@ def test_cli_uuid5_ouputted_with_valid_namespace_and_name(self):
|
775 | 775 | class TestUUIDWithoutExtModule(BaseTestUUID, unittest.TestCase):
|
776 | 776 | uuid = py_uuid
|
777 | 777 |
|
| 778 | + |
778 | 779 | @unittest.skipUnless(c_uuid, 'requires the C _uuid module')
|
779 | 780 | class TestUUIDWithExtModule(BaseTestUUID, unittest.TestCase):
|
780 | 781 | uuid = c_uuid
|
781 | 782 |
|
| 783 | + def check_has_stable_libuuid_extractable_node(self): |
| 784 | + if not self.uuid._has_stable_extractable_node: |
| 785 | + self.skipTest("libuuid cannot deduce MAC address") |
| 786 | + |
| 787 | + @unittest.skipUnless(os.name == 'posix', 'POSIX only') |
| 788 | + def test_unix_getnode_from_libuuid(self): |
| 789 | + self.check_has_stable_libuuid_extractable_node() |
| 790 | + script = 'import uuid; print(uuid._unix_getnode())' |
| 791 | + _, n_a, _ = assert_python_ok('-c', script) |
| 792 | + _, n_b, _ = assert_python_ok('-c', script) |
| 793 | + n_a, n_b = n_a.decode().strip(), n_b.decode().strip() |
| 794 | + self.assertTrue(n_a.isdigit()) |
| 795 | + self.assertTrue(n_b.isdigit()) |
| 796 | + self.assertEqual(n_a, n_b) |
| 797 | + |
| 798 | + @unittest.skipUnless(os.name == 'nt', 'Windows only') |
| 799 | + def test_windows_getnode_from_libuuid(self): |
| 800 | + self.check_has_stable_libuuid_extractable_node() |
| 801 | + script = 'import uuid; print(uuid._windll_getnode())' |
| 802 | + _, n_a, _ = assert_python_ok('-c', script) |
| 803 | + _, n_b, _ = assert_python_ok('-c', script) |
| 804 | + n_a, n_b = n_a.decode().strip(), n_b.decode().strip() |
| 805 | + self.assertTrue(n_a.isdigit()) |
| 806 | + self.assertTrue(n_b.isdigit()) |
| 807 | + self.assertEqual(n_a, n_b) |
| 808 | + |
782 | 809 |
|
783 | 810 | class BaseTestInternals:
|
784 | 811 | _uuid = py_uuid
|
|
0 commit comments