Skip to content

Fix error assertion handling in approx when None in dict comparison - #11178

Merged
Zac-HD merged 3 commits into
pytest-dev:mainfrom
kenny-y-dev:add-none-support-approxmapping
Jul 8, 2023
Merged

Zac-HD merged 3 commits into
pytest-dev:mainfrom
kenny-y-dev:add-none-support-approxmapping

Conversation

@kenny-y-dev

Copy link
Copy Markdown
Contributor

Closes #10702

Dict comparsion in the ApproxMapping class did not check if values were None before attempting to subtract for max_abs_diff stat, which was throwing an TypeError instead of being handled by pytest error assertion. Check for None has been added before these calculations, so that None will properly show as Obtained/Expected in pytest assert message

Dict comparsion in the ApproxMapping class did not check if values were None before attempting to subtract for max_abs_diff stat, which was throwing an TypeError instead of being handled by pytest error assertion. Check for None has been added before these calculations, so that None will properly show as Obtained/Expected in pytest assert message

@nicoddemus nicoddemus 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.

Thanks a lot @kenny-y-dev, we appreciate another contribution!

Comment thread src/_pytest/python_api.py Outdated
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.

pytest.approx fails with TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

3 participants