Skip to content

test(mintest): fail if unexpected third-party packages are installed - #2782

Merged
vytas7 merged 5 commits into
falconry:masterfrom
danielvjs:test/1790-mintest-dep-check
Nov 11, 2026
Merged

vytas7 merged 5 commits into
falconry:masterfrom
danielvjs:test/1790-mintest-dep-check

Conversation

@danielvjs

Copy link
Copy Markdown
Contributor

Summary of Changes

As discussed in #1790 (question, my reply), mintest already 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.

  • Add tools/check_no_third_party_deps.py, which computes the requirement closure of the allowed distributions via importlib.metadata and exits with an error if anything else (besides pip/setuptools/wheel) is installed.
  • Run it as the first mintest command, with falcon coverage pytest as the allowed set, so the env fails early instead of silently running with extra packages.

Verification: tox -e mintest passes (check OK, then the usual test run). As a negative test, installing an extra package (six) into the env makes the check fail with Unexpected distributions installed: six. The full tox gate passes locally except for one intermittent Windows-only teardown error in test_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

  • Applied changes to both WSGI and ASGI code paths and interfaces (where applicable).
  • Added tests for changed code.
  • Performed automated tests and code quality checks by running tox.
  • Prefixed code comments with GitHub nick and an appropriate prefix.
  • Coding style is consistent with the rest of the framework.
  • Updated documentation for changed code.
    • Added docstrings for any new classes, functions, or modules.
    • Updated docstrings for any modifications to existing code.
    • Updated both WSGI and ASGI docs (where applicable).
    • Added references to new classes, functions, or modules to the relevant RST file under docs/.
    • Updated all relevant supporting documentation files under docs/.
    • A copyright notice is included at the top of any new modules (using your own name or the name of your organization).
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • Changes (and possible deprecations) have towncrier news fragments under docs/_newsfragments/, with the file name format {issue_number}.{fragment_type}.rst.
  • LLM output, if any, has been carefully reviewed and tested by a human developer.

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

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ff96e13) to head (2df2bba).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vytas7 vytas7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@danielvjs

Copy link
Copy Markdown
Contributor Author

Thanks @vytas7! Done: I moved the check into tools/test_dist.py and reverted the mintest change. packaging and pytest are now installed explicitly before the package under test, and right after installing Falcon the venv is checked to contain nothing beyond the requirement closure of falcon, packaging and pytest (plus pip, which venv bootstraps; setuptools and wheel are no longer special-cased). Only then is the rest of requirements/cibwtest installed. I tested it on Linux with both the sdist and the wheel, plus a negative test with an extra package (six) installed.

@danielvjs
danielvjs requested a review from vytas7 November 10, 2026 03:57

@vytas7 vytas7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

@vytas7
vytas7 merged commit d3cf7d9 into falconry:master Nov 11, 2026
70 checks passed
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

Successfully merging this pull request may close these issues.

4 participants