-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-89083: Add CLI tests for UUIDv{6,7,8}
#136548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you:
- follow PEP-8 (1 blank line between functions)
- make a separate class that is only testing the CLI functionality please?
Done. Thanks! Edited: btw, we've got tested like this: class TestUUIDWithoutExtModule(BaseTestUUID, unittest.TestCase):
uuid = py_uuid In this current PR code, this test in redundant. I suggest maybe we could combine them together (?) |
Lib/test/test_uuid.py
Outdated
@@ -1140,6 +1140,9 @@ def test_uuid_weakref(self): | |||
weak = weakref.ref(strong) | |||
self.assertIs(strong, weak()) | |||
|
|||
|
|||
class TestUUIDCli(BaseTestUUID, unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all CAPS on term CLI
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just check how other classes testing CLIs are named.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of duplicated code. I would sugfgest having a single a single function that tests the expected outputs accordingly:
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_uuid1(self):
self.do_test_standalone_uuid(1)
and similar stuff for v6, v7 and v8.
In the test case of cli we've actually already tested UUID without ext moudle (?, I'm not quiet sure) So maybe combining them together will be better? |
Lib/test/test_uuid.py
Outdated
@@ -1140,6 +1140,9 @@ def test_uuid_weakref(self): | |||
weak = weakref.ref(strong) | |||
self.assertIs(strong, weak()) | |||
|
|||
|
|||
class TestUUIDCli(BaseTestUUID, unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just check how other classes testing CLIs are named.
It's not entirely redundant. However I see the issue. Two possibilities:
Or:
|
Ok, actually |
The test classes before are named in testUUID* (which I think would be better if we add this prefix in this func). But yes |
This is better IMO. I've changed it. |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
UUIDv{6,7,8}
This PR add simple cli test cases to UUIDv6, v7, v8 added in #89083 , as well as a test case to UUID v1.
There are only one test cases for each, since they can't be customized through CLI.
Skipping news ;)