I'm using pytest with mock in my python project.
When I get a test failure that involves a mock object (almost all of them), the traceback dives into the mock library source code and my code that's actually triggering the failure often scrolls out of view.
Is there a way to tell py.test to exclude installed libraries from the traceback or something like that? The noise level is taking away from what is otherwise a sweet testing library.
pytest has the option -x or --exitfirst which stops the execution of the tests instanly on first error or failed test. pytest also has the option --maxfail=num in which num indicates the number of errors or failures required to stop the execution of the tests.
In the selected directories, pytest looks for test_*. py or *_test.py files.
While the pytest discovery mechanism can find tests anywhere, pytests must be placed into separate directories from the product code packages. These directories may either be under the project root or under the Python package.
There is a hack: a function defining the local variable __tracebackhide__
will not be shown. Example:
def some_support_code(x, y):
__tracebackhide__ = True
assert x == y
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With