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

Is there a way to opt out of PytestReturnNotNoneWarning ? #10427

Closed
pllim opened this issue Oct 25, 2022 · 5 comments
Closed

Is there a way to opt out of PytestReturnNotNoneWarning ? #10427

pllim opened this issue Oct 25, 2022 · 5 comments

Comments

@pllim
Copy link
Contributor

pllim commented Oct 25, 2022

As of pytest 7.2.0 , any test function that returns something not a None now gets a PytestReturnNotNoneWarning. Looking at its memo in https://github.com/pytest-dev/pytest/blob/main/doc/en/deprecations.rst , I do not see a way to tell pytest, "It's okay, this return is intentional, just let it return stuff and not emit the warning."

How do I opt out of this warning?

What's the problem this feature will solve?

This will let me keep using https://github.com/matplotlib/pytest-mpl plugin because it requires returning the Matplotlib figure object for image comparison.

Describe the solution you'd like

Let me opt out.

Alternative Solutions

Tell https://github.com/matplotlib/pytest-mpl devs how to rework their plugin to not return stuff.

Additional context

astropy/astropy#13892 (we do not want to pin maxversion of pytest if we can help it)

@nicoddemus
Copy link
Member

@pllim you can configure filterwarnings to ignore that warning.

But this brings to attention that pytest-mpl probably needs to be updated, as we plan to make this a hard error in the future (following unittest, which is going in the same direction).

@pllim
Copy link
Contributor Author

pllim commented Oct 25, 2022

@nicoddemus , ignoring warning won't solve the problem when you turn it into exception though.

@nicoddemus
Copy link
Member

nicoddemus commented Oct 25, 2022

Nope it won't, that's why I said "pytest-mpl probably needs to be updated".

@pllim
Copy link
Contributor Author

pllim commented Oct 25, 2022

Okay. I also asked at matplotlib/pytest-mpl#183 🤞

@The-Compiler
Copy link
Member

Also see #10421

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

No branches or pull requests

3 participants