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

Test inside pytest_runtest_call hook #36

Merged
merged 4 commits into from
Sep 11, 2023

Conversation

ConorMacBride
Copy link
Member

@ConorMacBride ConorMacBride commented Oct 25, 2022

This changes the plugin's pytest integration to be the same as pytest-mpl, which is able to handle intercepting returned values for further testing.

Fix #35

@ConorMacBride
Copy link
Member Author

@pllim I think the CI workflow is disabled

@pllim
Copy link
Member

pllim commented Oct 25, 2022

Let me close/reopen.

@pllim pllim closed this Oct 25, 2022
@pllim pllim reopened this Oct 25, 2022
@pllim
Copy link
Member

pllim commented Oct 25, 2022

Might have to drop Python 3.7 ?

@ConorMacBride
Copy link
Member Author

Could just ignore the warning? Which would you prefer?

@ConorMacBride ConorMacBride marked this pull request as ready for review October 25, 2022 22:37
@pllim
Copy link
Member

pllim commented Oct 25, 2022

Ah, true, you could.

@pllim
Copy link
Member

pllim commented Oct 26, 2022

Thanks. I don't grok the internals here, so I pinged the people who has release rights for review (https://pypi.org/project/pytest-arraydiff).

@ConorMacBride
Copy link
Member Author

#35 should only be an issue when pytest-arraydiff is either not installed or not enabled. I think it's also worth updating for the enabled case here because we found that the existing wrapper method didn't test class based tests.

@pllim
Copy link
Member

pllim commented Oct 26, 2022

I think it's also worth updating for the enabled case here because we found that the existing wrapper method didn't test class based tests.

Do you plan to do that in this PR? If not, please open a new issue for it. Thanks!

@ConorMacBride
Copy link
Member Author

I already fixed that in the first commit. I was just justifying the change which I later realised wasn't necessary to fix the actual issue referenced. 😆

I've now confirmed that pytest-arraydiff doesn't work with class-based tests on recent pytest versions. You can see in the logs that it only shows the warning for the class test (because it wasn't able to wrap the test method for array testing): https://github.com/astropy/pytest-arraydiff/actions/runs/2914788915/jobs/4644034561#step:5:148

I tried modifying the return value of tests/test_pytest_arraydiff.py::TestClass::test_succeeds_class, however, it always passed on the main branch. Although, with this PR it failed as expected when modified.

@pllim pllim added the bug label Oct 26, 2022
@pllim
Copy link
Member

pllim commented Oct 26, 2022

If you don't hear back from the actual package maintainers, try poke them on Astropy Slack. Thanks!

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

minor comment only, you need Tom to sign off on the actual code changes

setup.cfg Show resolved Hide resolved
@astrofrog
Copy link
Member

I will try and review this shortly.

I do wonder if there would be scope to develop a pytest plugin that deals with getting return values that both pytest-mpl and this plugin could depend on to avoid duplicating infrastructure?

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@astrofrog astrofrog merged commit e006ea1 into astropy:main Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pytest-arraydiff causes PytestReturnNotNoneWarning in Pytest 7.2
4 participants