Repository navigation
test(mintest): fail if unexpected third-party packages are installed - #2782
Conversation
The mintest env already runs the test suite with only the packages from requirements/mintest, which covers most of what falconry#1790 asks for. However, nothing actually verified that the virtualenv was free of other distributions, which could accidentally mask missing-dependency issues. Add tools/check_no_third_party_deps.py, which computes the requirement closure of the allowed distributions via importlib.metadata, and run it as the first mintest command so that the env fails early if anything else (besides installer tooling) is present. Refs falconry#1790
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2782 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 64 64
Lines 8121 8121
Branches 1131 1131
=========================================
Hits 8121 8121 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vytas7
left a comment
There was a problem hiding this comment.
Thanks for this PR @danielvjs!
While I do like this improvement, on reconsideration, could we instead fold this logic into tools/test_dist.py?
There we do not install coverage, so 1 package less to inspect, making this check even purer.
Also, as I understand, we rely on the fact that packaging comes as a pytest dependency, however, that may not be guaranteed going forward. So it is probably better to install both packaging and pytest explicitly in that tool.
In addition, I don't want to special-case setuptools and wheel there. They should not be present in a modern setting.
As suggested in review, move the check from the mintest env to tools/test_dist.py, where coverage is not installed, so the check is even stricter. packaging and pytest are now installed explicitly before the package under test, the package is installed, and then the venv is verified to contain no distributions beyond the requirement closure of falcon, packaging and pytest (plus pip, which venv bootstraps). Only after that are the rest of the test requirements installed. setuptools and wheel are no longer special-cased, as they should not be present in a modern setup. Refs falconry#1790
|
Thanks @vytas7! Done: I moved the check into |
Summary of Changes
As discussed in #1790 (question, my reply),
mintestalready covers the goal of that issue much better than a separate smoke env would. This PR adds the one piece that was still missing: actually verifying that the virtualenv is free of other distributions.tools/check_no_third_party_deps.py, which computes the requirement closure of the allowed distributions viaimportlib.metadataand exits with an error if anything else (besides pip/setuptools/wheel) is installed.mintestcommand, withfalcon coverage pytestas the allowed set, so the env fails early instead of silently running with extra packages.Verification:
tox -e mintestpasses (check OK, then the usual test run). As a negative test, installing an extra package (six) into the env makes the check fail withUnexpected distributions installed: six. The fulltoxgate passes locally except for one intermittent Windows-only teardown error intest_asgi_servers.py(uvicorn not exiting in time), which passes when rerun and is unrelated to this change. No news fragment, since this only touches the test tooling.If you'd rather not have this check, feel free to close this PR and the issue — no hard feelings!
Disclosure: an AI coding assistant helped write this change. I reviewed and tested every line myself.
Related Issues
#1790
Pull Request Checklist
tox.docs/.docs/.versionadded,versionchanged, ordeprecateddirectives.docs/_newsfragments/, with the file name format{issue_number}.{fragment_type}.rst.