pydicom / deid

best effort anonymization for medical images using python
https://pydicom.github.io/deid/
MIT License
138 stars 43 forks source link

Fix pytest import errors, configure coverage. #217

Closed jstorrs closed 1 year ago

jstorrs commented 1 year ago

Description

Running pytest results in a stream of ModuleNotFoundError: No module named 'deid.tests' errors/failures similar to

_____________ ERROR collecting deid/tests/test_clean.py _____________
ImportError while importing test module '/home/jstorrs/src/deid/deid/tests/test_clean.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
deid/tests/test_clean.py:19: in <module>
    from deid.tests.common import get_file
E   ModuleNotFoundError: No module named 'deid.tests'

This is resolved by adding an empty deid/tests/__init__.py

Checklist

Open questions

I don't know whether adding __init__.py has any implications for packaging/CI etc.

jstorrs commented 1 year ago

The second patch configures coverage. pytest --cov reports coverage is 64.23% on the branch I'm using, so for now I set the required coverage at 50% to avoid adding new failures.

vsoch commented 1 year ago

This all looks good to me, thanks @jstorrs !