Skip to Main Content
Python Testing with pytest
book

Python Testing with pytest

by Brian Okken
February 2022
Intermediate to advanced content levelIntermediate to advanced
274 pages
6h 28m
English
Pragmatic Bookshelf
Content preview from Python Testing with pytest

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 ====================== ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Testing with pytest

Python Testing with pytest

Brian Okken

Publisher Resources

ISBN: 9781680509427Errata Page