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

Yield test deprecation warning spams too much #2562

Closed
pv opened this issue Jul 10, 2017 · 8 comments
Closed

Yield test deprecation warning spams too much #2562

pv opened this issue Jul 10, 2017 · 8 comments
Labels
plugin: warnings related to the warnings builtin plugin topic: reporting related to terminal output and user-facing messages and errors

Comments

@pv
Copy link
Contributor

pv commented Jul 10, 2017

While working on scipy/scipy#7572 I noticed that pytest emits the "yield tests are deprecated, and scheduled to be removed in pytest 4.0" warning for each generated test, not per each test generator. (And for scipy, this means the message is printed 15652 times :) -- of course we'll eventually plan to refactor them completely away, but that takes some time.)

There are workarounds such as --disable-warnings and tagging | uniq to the end, but it would be nice if this was fixed to be less spammy on the pytest end.

As far as I understand, there's no way to disable this deprecation warning in pytest.ini without also disabling the whole warning capture mechanism (which is what --disable-pytest-warnings et al seem to do)?

Minimal repro:

# python -mpytest test_foo.py
def test_foo():
    for k in range(10000):
        yield lambda x: None, k
``` plat: Linux $ python --version Python 2.7.13 $ pip list pip (9.0.1) py (1.4.34) pytest (3.1.3) setuptools (36.0.1) wheel (0.29.0) ```
@nicoddemus
Copy link
Member

Agreed on issuing the warning only once per generator.

To suppress those warnings you can add this to your pytest.ini:

[pytest]
filterwarnings =
    ignore:.*yield tests are deprecated.*

@nicoddemus nicoddemus added plugin: warnings related to the warnings builtin plugin topic: reporting related to terminal output and user-facing messages and errors labels Jul 10, 2017
@pv
Copy link
Contributor Author

pv commented Jul 10, 2017 via email

@nicoddemus
Copy link
Member

Hmm yeah I didn't test it, sorry. Those parameters are passed to warnings.filterwarnings, so if you can find how to silence them using warnings.filterwarnings you should be able to set that in your pytest.ini.

@pv
Copy link
Contributor Author

pv commented Jul 10, 2017

This deprecation warning seems to be emitted at _pytest/python.py:618 directly by self.config.warn so it doesn't go through the Python warning mechanism. (Maybe changing it to warnings.warn would be enough?) Or just dedent by 4 spaces?

@nicoddemus
Copy link
Member

Oh you are right, sorry about that. Indeed we would have to change it to raise an actual warning.

@nicoddemus
Copy link
Member

xref: #1043

@pv
Copy link
Contributor Author

pv commented Jul 10, 2017

I'll submit a pull request removing the four spaces in a moment :)
Maybe it makes sense to emit it only once per each generator function.

@nicoddemus
Copy link
Member

Fixed in #2563

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: warnings related to the warnings builtin plugin topic: reporting related to terminal output and user-facing messages and errors
Projects
None yet
Development

No branches or pull requests

2 participants