February 2022
Intermediate to advanced
274 pages
6h 28m
English
We’ve been running coverage on an installed package, cards. But there’s a lot more to the Python world than just building installable packages. In addition to packages, we can ask coverage to pay attention to directories and files as well. Let’s take a look at running coverage on a directory.
In the ch9/some_code directory, we have a couple source code modules and a test module:
| | $ tree ch9/some_code |
| | ch9/some_code |
| | ├── bar_module.py |
| | ├── foo_module.py |
| | └── test_some_code.py |
To demonstrate pointing coverage at a path instead package, let’s stay in the top-level code directory and run the tests from there:
| | $ pytest --cov=ch9/some_code ch9/some_code/test_some_code.py |
| | ========================= ... |
Read now
Unlock full access