I have a small Python 3 project that I intend to keep as a reusable library. Let's call it utils_common. The coverage report from coverage.py includes some coverage for actual unit tests code along "production" code and I think I'm doing something wrong here.
The directory structure is:
utils_common_prj (root project directory)
utils_common (directory, actual code package)
__init__.py (empty file)
data_convert.py (some module with a class with static methods)
... (other modules with code)
tests (directory, test code package)
__init__.py. (empty file)
test_data_convert.py (unit test class, testing class DataConvert)
... (other unit tests)
setup.py (file, used to create the .tar.gz dist package)
.pylintrc
.gitignore
So I run unit tests with code coverage using coverage.py like so: having current directory utils_common_prj I run:
coverage run --source=. --omit=setup.py -m unittest discover
Followed by
coverage report
What I get is:
Name Stmts Miss Cover
-------------------------------------------------------------
utils_common/__init__.py 0 0 100%
utils_common/data_convert.py 10 0 100%
...
tests/__init__.py 0 0 100%
tests/test_data_convert.py 39 0 100%
...
-------------------------------------------------------------
TOTAL 222 0 100%
I am getting statement count and percentage from test code along with actual code and I don't think this is desirable.
Coming from a .NET and Java background this seems like an error. Is it an error? If so, how should I fix it?
coverage run --source=. --omit=setup.py,*test* -m unittest discoverleads tozsh: no matches found: --omit=setup.py,*test*. However, placing the omit value in quotes does the trick! Like so:coverage run --source=. --omit='setup.py,*test*' -m unittest discoverIt works now! Thanks!