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.

Enhance `RunResult` warning assertion capabilities

See original GitHub issue

while 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:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
symonkcommented, Jul 30, 2021

@nicoddemus sweet, will implement it this weekend, I wanna get a look at per-logger configuration/suppression as a capability as well

0reactions
nicoddemuscommented, Jul 31, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

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