-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add help page with tips and tricks for pytest.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
######################## | ||
Tips & Tricks for pytest | ||
######################## | ||
|
||
- Run in verbose/no-capture/fail first mode: | ||
|
||
.. prompt:: | ||
|
||
pytest -vsx | ||
|
||
v : | ||
verbose mode shows the result of each test individually | ||
|
||
s : | ||
no-capture shows results or print statements | ||
|
||
x : | ||
stop/fail on the first test failure | ||
|
||
|
||
- Show log messages: | ||
|
||
.. prompt:: | ||
|
||
pytest -vsx --log-cli-level DEBUG | ||
|
||
log-cli-level : | ||
controls the log level for the command line at runtime. | ||
This allows you to see the log messages as the test runs without the need to fiddle with python logger. | ||
You can also use different levels; INFO, WARNING and ERROR. | ||
|
||
- Run a single test file (e.g. the one you are working on): | ||
|
||
.. prompt:: | ||
|
||
pytest -vsx tests/test_maintel_disable_m1m3_balance_system.py | ||
|
||
|
||
- Run a single test from a single file (e.g. debugging a specific error): | ||
|
||
.. prompt:: | ||
|
||
pytest -vsx tests/test_maintel_disable_m1m3_balance_system.py -k test_executable | ||
|
||
This will actually do a regular expression match in the test name, so it will actually run everything that matches “test_executable”. |