question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[prerelease] pytest.warns() doesn't seem to work properly for coverage.py

See original GitHub issue

From @nedbat via Twitter:

This message could be better, because removing None doesn’t work now:

PytestRemovedIn8Warning: Passing None to catch any warning has been deprecated, pass no arguments instead:
  Replace pytest.warns(None) by simply pytest.warns().

When I remove None and run with pytest 7, I get failures:

image

No idea off-hand what’s going on there, as that seems exactly what we did in #8677 too.

cc @Zac-HD @olgarithms

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
nedbatcommented, Dec 8, 2021

We never actually had that though! Before, it would pass for any or no warnings, which would be useless if it wasn’t also misleading.

I see! I was definitely misunderstanding it then. If a new context manager isn’t available in 7.0, I can write one of my own for my test suite. Thanks.

1reaction
The-Compilercommented, Dec 7, 2021

Ah, makes sense! I guess in @nedbat’s scenario indeed the warning is “optional”. So I suppose we can close this one as a duplicate then?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve pytest.warns() docs to clarify difference with ...
Zac-HD mentioned this issue on Dec 7, 2021. [prerelease] pytest.warns() doesn't seem to work properly for coverage.py #9386.
Read more >
Release 7.0.0b1 unknown
Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts.
Read more >
How to capture warnings
This test will fail if myfunction does not issue a deprecation warning when called with a 17 argument. Asserting warnings with the warns...
Read more >
py.test gives Coverage.py warning: Module sample.py was ...
Anyone has an idea why coverage.py does not work? hence, if I run coverage run -m py.test test.py separately, it does not show...
Read more >
pytest Documentation
pytest will run all files of the form test_*.py or *_test.py in the ... Note: Calling pytest.main() will result in importing your tests...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found