Skip to content

test_enum has duplicate test cases: function vs class based enum definitions #109774

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

Closed
sobolevn opened this issue Sep 23, 2023 · 1 comment
Closed
Assignees
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Sep 23, 2023

Bug report

cpython/Lib/test/test_enum.py

Lines 1034 to 1047 in 5e7ea95

class TestPlainEnumClass(_EnumTests, _PlainOutputTests, unittest.TestCase):
enum_type = Enum
class TestPlainEnumFunction(_EnumTests, _PlainOutputTests, unittest.TestCase):
enum_type = Enum
class TestPlainFlagClass(_EnumTests, _PlainOutputTests, _FlagTests, unittest.TestCase):
enum_type = Flag
class TestPlainFlagFunction(_EnumTests, _PlainOutputTests, _FlagTests, unittest.TestCase):
enum_type = Flag

Looks like some cases here are just duplicates: because in some cases Function and Class tests have different enum_type definitions:

cpython/Lib/test/test_enum.py

Lines 1104 to 1109 in 5e7ea95

class TestMixedIntClass(_EnumTests, _MixedOutputTests, unittest.TestCase):
class enum_type(int, Enum): pass
class TestMixedIntFunction(_EnumTests, _MixedOutputTests, unittest.TestCase):
enum_type = Enum('enum_type', type=int)

But, some have identical. I propose to delete cases where enum_type is a duplicate.
I have a PR ready.

It was introduced in #108704
CC @ethanfurman

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir stdlib Python modules in the Lib dir labels Sep 23, 2023
@sobolevn sobolevn self-assigned this Sep 23, 2023
sobolevn added a commit to sobolevn/cpython that referenced this issue Sep 23, 2023
@ethanfurman ethanfurman self-assigned this Sep 23, 2023
@ethanfurman
Copy link
Member

Those duplicates are intentional -- the functional creation tests excercise different code than the class creation tests.

@itamaro itamaro closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants