Enhance `RunResult` warning assertion capabilities
See original GitHub issuewhile writing some other bits and pieces, I had a use case for checking the warnings omitted, RunResult has a assert_outcomes() that doesn’t quite offer warnings= yet the information is already available in there, I suspect there is a good reason why we don’t have assert_outcomes(warnings=...) so I propose some additional capabilities on RunResult to handle warnings in isolation.
With assert_outcomes() the full dict comparison may get a bit intrusive as far as warning capture is concerned.
something simple like:
result = pytester.runpytest(...)
result.assert_warnings(count=1)
Thoughts?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
unittest — Unit testing framework — Python 3.11.1 ...
The crux of each test is a call to assertEqual() to check for an expected result; assertTrue() or assertFalse() to verify a condition;...
Read more >Writing plugins — pytest documentation
One of the main features of pytest is the use of plain assert statements and the ... in the tests root directory is...
Read more >How to use pytest to assert NO Warning is raised
To ensure it works: adding warnings.warn('any message') in the second assertion let the test fail. Share.
Read more >pytest Documentation - Read the Docs
Use the raises helper to assert that some code raises an exception: # content of test_sysexit.py import pytest def f(): raise SystemExit(1).
Read more >Assertions - Go Packages
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@nicoddemus sweet, will implement it this weekend, I wanna get a look at per-logger configuration/suppression as a capability as well
Yeah I think that’s a natural addition. 👍 I didn’t take a closer look at #8952 because it was closed by the time I got to it, hehehe.