Up to now we call py.test
via Jenkins.
If a test fails, we see the usual stacktrace like this
Traceback (most recent call last):
File "/home/u/src/foo/bar/tests/test_x.py", line 36, in test_schema_migrations
errors, out))
AssertionError: Unknown output: ["Migrations for 'blue':", ...]
It would be really great, if I could see local variables like in the django debug page (See https://djangobook.com/wp-content/uploads/figure2_3a.png).
.... But they should only be visible if I want to see them. I guess this means I need a different format than text. Maybe HTML?
Is there a way to enable this?
I never used the tool Sentry. But AFAIK this can display nice tracebacks with local variables.
Running pytest -vv should make your output more verbose. If you want your output to be less verbose, try pytest -q or pytest --quiet .
Running pytest We can run a specific test file by giving its name as an argument. A specific function can be run by providing its name after the :: characters. Markers can be used to group tests. A marked grouped of tests is then run with pytest -m .
The -v flag controls the verbosity of pytest output in various aspects: test session progress, assertion details when tests fail, fixtures details with --fixtures , etc.
Use -l
/--showlocals
option:
pytest --showlocals # show local variables in tracebacks pytest -l # show local variables (shortcut)
example:
def foo():
a = 1
> assert 0
E assert 0
a = 1
test_foo.py:8: AssertionError
see more details in the doc.
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