Skip to content
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

bpo-46296: add a test case for enum.py which covers _use_args == True and _member_type_ == object #30458

Merged
merged 5 commits into from Jan 7, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 7, 2022

If I am missing something and _member_type_ can be object while _use_args_ is True, then this PR can be converted into a coverage increasing one.

I will just add a sample to cover this case (but, again, I can't come up with one).

https://bugs.python.org/issue46296

@sobolevn
Copy link
Member Author

sobolevn commented Jan 7, 2022

asyncio test sometimes fails on win, reopening.

@sobolevn sobolevn closed this Jan 7, 2022
@sobolevn sobolevn reopened this Jan 7, 2022
Copy link
Member

@ethanfurman ethanfurman left a comment

Choose a reason for hiding this comment

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

The premise is indeed untrue: _use_args_ can be True when _member_type_ is object.

The branch is taken under rare conditions with a mixed-in type has a __new__ with a complicated method of determining the value attribute.

The branch is taken when a custom __new__ has been defined: _use_args_ will then be True, and if _value_ has not been set then __set_name__ will try to call object.__new__(cls, *args) which will fail. The if _member_type_ is object branch is there to set the _value_ attribute, since it can.

@sobolevn
Copy link
Member Author

sobolevn commented Jan 7, 2022

@ethanfurman yes, you are right. Now this case is covered.

@sobolevn sobolevn changed the title bpo-46296: removes unreachable condition in enum.py bpo-46296: add a test case for enum.py which covers _use_args == True and _member_type_ == object Jan 7, 2022
Copy link
Member

@ethanfurman ethanfurman left a comment

Choose a reason for hiding this comment

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

Nice. Thanks.

@sobolevn
Copy link
Member Author

sobolevn commented Jan 7, 2022

Thank you! Several other missing branches left 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants