Open andymwood opened 1 year ago
__del__
methods are very difficult. In your case, the method is being called during interpreter shutdown, so possibly after coverage has stopped measurement. They can cause other troubles as well (see the pink warning box at https://docs.python.org/3/reference/datamodel.html#object.__del__). You might want to consider refactoring to avoid the need for __del__
.
In the meantime, you can add a pragma comment to indicate that you understand the line will not be measured: https://coverage.readthedocs.io/en/7.2.7/excluding.html#excluding-code-from-coverage-py
Summary
The following problem has two objects that reference each other and a
__del__
method in one of the classes. pytest-cov incorrectly reports that the__del__
method hasn't been called.Expected vs actual result
Expected 100% coverage. Get 91% coverage.
Reproducer
Versions
Code
test_module.py: