Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module x was previously imported, but not measured (module-not-measured) #664

Open
graingert-coef opened this issue Oct 17, 2024 · 3 comments

Comments

@graingert-coef
Copy link

Summary

when running with pytest-cov I get a ' Module x was previously imported, but not measured (module-not-measured)' but it is actually measured.

see the output here:
https://github.com/graingert-coef/coverage-test/actions/runs/11383996856/job/31670778809#step:4:33

full reproducer here: https://github.com/graingert-coef/coverage-test/

@graingert-coef
Copy link
Author

graingert-coef commented Oct 17, 2024

the problem seems to be related to the fact that you end up with ['coverage_test', 'coverage_test'] in self.source_pkgs_unmatched and coverage only removes on instance of it

https://github.com/nedbat/coveragepy/blob/fb2b49fb1beb810c6d7ee1cfbbf75a3ff8574fbf/coverage/inorout.py#L199

@graingert-coef
Copy link
Author

according to this

help='Path or package name to measure during execution (multi-allowed). '
'Use --cov= to not do any source filtering and record everything.',
I can set --cov= but that also results in a warning:

https://github.com/graingert-coef/coverage-test/pull/1/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711R25
https://github.com/graingert-coef/coverage-test/actions/runs/11384119440/job/31671155042?pr=1#step:4:33

in this case you end up with ['', 'coverage_test'] in self.source_pkgs_unmatched

@graingert-coef
Copy link
Author

graingert-coef commented Oct 17, 2024

If I set "--cov", this works fine - but then running pipx run tox -- src/coverage_test/tests/test_app.py the --cov consumes the path arg and I get CoverageWarning: Module src/coverage_test/tests/test_app.py was never imported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant