mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.14] gh-89083: Add CLI tests for UUIDv{6,7,8} (GH-136548) (#136576)
Some checks are pending
Tests / Windows MSI (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / Windows MSI (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
gh-89083: Add CLI tests for `UUIDv{6,7,8}` (GH-136548)
(cherry picked from commit c564847e98)
Co-authored-by: Weilin Du <108666168+LamentXU123@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
ac807cb3a0
commit
33f561d7be
1 changed files with 31 additions and 2 deletions
|
|
@ -1140,6 +1140,23 @@ class BaseTestUUID:
|
|||
weak = weakref.ref(strong)
|
||||
self.assertIs(strong, weak())
|
||||
|
||||
|
||||
class CommandLineTestCases:
|
||||
uuid = None # to be defined in subclasses
|
||||
|
||||
def do_test_standalone_uuid(self, version):
|
||||
stdout = io.StringIO()
|
||||
with contextlib.redirect_stdout(stdout):
|
||||
self.uuid.main()
|
||||
output = stdout.getvalue().strip()
|
||||
u = self.uuid.UUID(output)
|
||||
self.assertEqual(output, str(u))
|
||||
self.assertEqual(u.version, version)
|
||||
|
||||
@mock.patch.object(sys, "argv", ["", "-u", "uuid1"])
|
||||
def test_cli_uuid1(self):
|
||||
self.do_test_standalone_uuid(1)
|
||||
|
||||
@mock.patch.object(sys, "argv", ["", "-u", "uuid3", "-n", "@dns"])
|
||||
@mock.patch('sys.stderr', new_callable=io.StringIO)
|
||||
def test_cli_namespace_required_for_uuid3(self, mock_err):
|
||||
|
|
@ -1214,13 +1231,25 @@ class BaseTestUUID:
|
|||
self.assertEqual(output, str(uuid_output))
|
||||
self.assertEqual(uuid_output.version, 5)
|
||||
|
||||
@mock.patch.object(sys, "argv", ["", "-u", "uuid6"])
|
||||
def test_cli_uuid6(self):
|
||||
self.do_test_standalone_uuid(6)
|
||||
|
||||
class TestUUIDWithoutExtModule(BaseTestUUID, unittest.TestCase):
|
||||
@mock.patch.object(sys, "argv", ["", "-u", "uuid7"])
|
||||
def test_cli_uuid7(self):
|
||||
self.do_test_standalone_uuid(7)
|
||||
|
||||
@mock.patch.object(sys, "argv", ["", "-u", "uuid8"])
|
||||
def test_cli_uuid8(self):
|
||||
self.do_test_standalone_uuid(8)
|
||||
|
||||
|
||||
class TestUUIDWithoutExtModule(CommandLineTestCases, BaseTestUUID, unittest.TestCase):
|
||||
uuid = py_uuid
|
||||
|
||||
|
||||
@unittest.skipUnless(c_uuid, 'requires the C _uuid module')
|
||||
class TestUUIDWithExtModule(BaseTestUUID, unittest.TestCase):
|
||||
class TestUUIDWithExtModule(CommandLineTestCases, BaseTestUUID, unittest.TestCase):
|
||||
uuid = c_uuid
|
||||
|
||||
def check_has_stable_libuuid_extractable_node(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue