Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
gh-89083: Add CLI tests forUUIDv{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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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:
- followPEP-8 (1 blank line between functions)
- make a separate class that is only testing the CLI functionality please?
LamentXU123 commentedJul 11, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Done. Thanks! Edited: btw, we've got tested like this: classTestUUIDWithoutExtModule(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 termCLI
?
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.
picnixz left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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:
defdo_test_standalone_uuid(self,version):stdout=io.StringIO()withcontextlib.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"])deftest_uuid1(self):self.do_test_standalone_uuid(1)
and similar stuff for v6, v7 and v8.
Uh oh!
There was an error while loading.Please reload this page.
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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
It's not entirely redundant. However I see the issue. Two possibilities:
Or:
|
picnixz commentedJul 11, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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. |
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
UUIDv{6,7,8}
c564847
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks! Should we backport this to 3.14? The new UUIDs are added in that version |
Thanks@LamentXU123 for the PR, and@picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
(cherry picked from commitc564847)Co-authored-by: Weilin Du <108666168+LamentXU123@users.noreply.github.com>Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
GH-136576 is a backport of this pull request to the3.14 branch. |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
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 ;)