Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
picnixz merged 13 commits intopython:mainfromLamentXU123:add_cli_tests_for_new_uuids
Jul 12, 2025

Conversation

LamentXU123
Copy link
Contributor

@LamentXU123LamentXU123 commentedJul 11, 2025
edited
Loading

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 ;)

@LamentXU123LamentXU123 changed the titlegh-89083: add cli tests for new UUID versionsgh-89083: Add cli tests for new UUID versionsJul 11, 2025
Copy link
Member

@picnixzpicnixz left a 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
Copy link
ContributorAuthor

LamentXU123 commentedJul 11, 2025
edited
Loading

followPEP-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:

classTestUUIDWithoutExtModule(BaseTestUUID,unittest.TestCase):uuid=py_uuid

In this current PR code, this test in redundant. I suggest maybe we could combine them together (?)

@@ -1140,6 +1140,9 @@ def test_uuid_weakref(self):
weak = weakref.ref(strong)
self.assertIs(strong, weak())


class TestUUIDCli(BaseTestUUID, unittest.TestCase):
Copy link
ContributorAuthor

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?

Copy link
Member

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.

Copy link
Member

@picnixzpicnixz left a comment
edited
Loading

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.

@LamentXU123
Copy link
ContributorAuthor

followPEP-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:

classTestUUIDWithoutExtModule(BaseTestUUID,unittest.TestCase):uuid=py_uuid

In this current PR code, this test in redundant. I suggest maybe we could combine them together (?)

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?

@@ -1140,6 +1140,9 @@ def test_uuid_weakref(self):
weak = weakref.ref(strong)
self.assertIs(strong, weak())


class TestUUIDCli(BaseTestUUID, unittest.TestCase):
Copy link
Member

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
Copy link
Member

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?

In this current PR code, this test in redundant. I suggest maybe we could combine them together (?)

It's not entirely redundant. However I see the issue. Two possibilities:

  • Make the CLI test a mixin class that doesn't inherit from test case
  • Create two subclasses that are test cases, one with the extension module, one without.

Or:

  • Make CLI tests a mixin class that doesn't inhert from test cases, without auuid field (you can add a dummy one just for autocompletion, but set it to None as it'll be subclassed later).
  • MakeTestUUIDWithoutExtModule andTestUUIDWithExtModule inherit from this mixin as well (in addition toBaseTestUUID).

@picnixz
Copy link
Member

picnixz commentedJul 11, 2025
edited
Loading

Ok, actuallyCommandLineTest is a more common name in the code base. Just use it, no need to mention UUID (search for "CommandLineTest" and you'll see)

@LamentXU123
Copy link
ContributorAuthor

Ok, actuallyCommandLineTest is a more common name in the code base. Just use it, no need to mention UUID (search for "CommandLineTest" and you'll see)

The test classes before are named in testUUID* (which I think would be better if we add this prefix in this func). But yesCommandLineTest only is more common one in the code base so it's OK.

@LamentXU123
Copy link
ContributorAuthor

Make the CLI test a mixin class that doesn't inherit from test case
Create two subclasses that are test cases, one with the extension module, one without.

This is better IMO. I've changed it.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@picnixzpicnixz changed the titlegh-89083: Add cli tests for new UUID versionsgh-89083: Add CLI tests for UUIDv{6,7,8}Jul 11, 2025
@picnixzpicnixz changed the titlegh-89083: Add CLI tests for UUIDv{6,7,8}gh-89083: Add CLI tests forUUIDv{6,7,8}Jul 11, 2025
@picnixzpicnixz merged commitc564847 intopython:mainJul 12, 2025
43 checks passed
@LamentXU123
Copy link
ContributorAuthor

Thanks! Should we backport this to 3.14? The new UUIDs are added in that version

@picnixzpicnixz added the needs backport to 3.14bugs and security fixes labelJul 12, 2025
@miss-islington-app
Copy link

Thanks@LamentXU123 for the PR, and@picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJul 12, 2025
(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>
@bedevere-app
Copy link

GH-136576 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJul 12, 2025
picnixz added a commit that referenced this pull requestJul 12, 2025
gh-89083: Add CLI tests for `UUIDv{6,7,8}` (GH-136548)(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>
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull requestJul 12, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz added a commit to picnixz/cpython that referenced this pull requestJul 13, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@picnixzpicnixzpicnixz approved these changes

Assignees
No one assigned
Labels
skip newstestsTests in the Lib/test dir
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@LamentXU123@picnixz@StanFromIreland

[8]ページ先頭

©2009-2025 Movatter.jp