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

Comments

Projects
None yet
2 participants
@pv
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

This comment has been minimized.

Member

nicoddemus commented Jul 10, 2017

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.*
@pv

This comment has been minimized.

Contributor

pv commented Jul 10, 2017

@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Jul 10, 2017

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

This comment has been minimized.

Contributor

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

This comment has been minimized.

Member

nicoddemus commented Jul 10, 2017

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

@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Jul 10, 2017

xref: #1043

@pv

This comment has been minimized.

Contributor

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

This comment has been minimized.

Member

nicoddemus commented Jul 13, 2017

Fixed in #2563

@nicoddemus nicoddemus closed this Jul 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment