Running pytest
With pytest installed, we can run test_passing(). This is what it looks like when it’s run:
| $ cd /path/to/code/ch1 |
| $ pytest test_one.py |
| ========================= test session starts ========================== |
| collected 1 item |
| |
| test_one.py . [100%] |
| |
| ========================== 1 passed in 0.01s =========================== |
The dot after test_one.py means that one test was run and it passed. The [100%] is a percentage indicator showing how much of the test suite is done so far. Because there is just one test in the test session, one test equals 100% of the tests. If you need more information, you can use -v or --verbose:
| $ pytest -v test_one.py |
| ===================== test session starts ====================== ... |
Get Python Testing with pytest now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.