FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-89083: Add CLI tests for `UUIDv{6,7,8}` by LamentXU123 · Pull Request #136548 · python/cpython · GitHub

/ cpython Public

gh-89083: Add CLI tests for UUIDv{6,7,8} - #136548

Merged
picnixz merged 13 commits into
python:mainfrom
LamentXU123:add_cli_tests_for_new_uuids
Jul 12, 2025
Merged

gh-89083: Add CLI tests for UUIDv{6,7,8}#136548
picnixz merged 13 commits into
python:mainfrom
LamentXU123:add_cli_tests_for_new_uuids

Conversation

LamentXU123 commented Jul 11, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

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

LamentXU123 changed the title gh-89083: add cli tests for new UUID versions gh-89083: Add cli tests for new UUID versions Jul 11, 2025

picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you:

  • follow PEP-8 (1 blank line between functions)
  • make a separate class that is only testing the CLI functionality please?

LamentXU123 requested a review from picnixz July 11, 2025 16:11

LamentXU123 commented Jul 11, 2025
edited
Loading

Copy link
Copy Markdown
Contributor Author

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 (?)

Comment thread Lib/test/test_uuid.py Outdated
self.assertIs(strong, weak())


class TestUUIDCli(BaseTestUUID, unittest.TestCase):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Do we need all CAPS on term CLI?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just check how other classes testing CLIs are named.

picnixz left a comment
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread Lib/test/test_uuid.py Outdated

Copy link
Copy Markdown
Contributor Author

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 (?)

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?

Comment thread Lib/test/test_uuid.py Outdated
self.assertIs(strong, weak())


class TestUUIDCli(BaseTestUUID, unittest.TestCase):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just check how other classes testing CLIs are named.

Comment thread Lib/test/test_uuid.py Outdated
Comment thread Lib/test/test_uuid.py

picnixz commented Jul 11, 2025

Copy link
Copy Markdown
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 a uuid field (you can add a dummy one just for autocompletion, but set it to None as it'll be subclassed later).
  • Make TestUUIDWithoutExtModule and TestUUIDWithExtModule inherit from this mixin as well (in addition to BaseTestUUID).

picnixz commented Jul 11, 2025
edited
Loading

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

Ok, actually CommandLineTest 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 yes CommandLineTest only is more common one in the code base so it's OK.

Copy link
Copy Markdown
Contributor Author

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.

Comment thread Lib/test/test_uuid.py Outdated
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Comment thread Lib/test/test_uuid.py Outdated
picnixz changed the title gh-89083: Add cli tests for new UUID versions gh-89083: Add CLI tests for UUIDv{6,7,8} Jul 11, 2025
picnixz changed the title gh-89083: Add CLI tests for UUIDv{6,7,8} gh-89083: Add CLI tests for UUIDv{6,7,8} Jul 11, 2025
picnixz merged commit c564847 into python:main Jul 12, 2025
43 checks passed

Copy link
Copy Markdown
Contributor Author

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

picnixz added the needs backport to 3.14 bugs and security fixes label Jul 12, 2025

Copy link
Copy Markdown

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 request Jul 12, 2025
(cherry picked from commit c564847)

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 Bot commented Jul 12, 2025

Copy link
Copy Markdown

GH-136576 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 12, 2025
picnixz added a commit that referenced this pull request Jul 12, 2025
gh-89083: Add CLI tests for `UUIDv{6,7,8}` (GH-136548)
(cherry picked from commit c564847)

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 request Jul 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 request Jul 13, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
) (python#136576)

pythongh-89083: Add CLI tests for `UUIDv{6,7,8}` (pythonGH-136548)
(cherry picked from commit c564847)

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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL