On this page
Two startup guards: the bare-run threshold that pushes full-suite runs through the sandbox runner, and refusal of a temp root inside the project root.
#python.src.stricttest.sandbox
#python.src.stricttest.sandbox
Bare-run refusal and the TMPDIR-inside-repo refusal.
Two independent startup guards:
- Bare-run threshold. A run collecting MORE than the threshold is treated
as a full-ish run and must go through the sandbox runner (which exports the sandbox env var). Small targeted runs stay bare-runnable so the inner development loop is fast -- the always-on env floor plus the push/chdir/socket guards still protect those.
- TMPDIR-inside-repo refusal. Fixture temp directories inside the repo let
unanchored git commands walk UP into the real repo and commit junk. Both the pytest --basetemp and the TMPDIR environment variable are checked against the repository root, which is derived from pytest's rootpath.
#enforce_threshold
def enforce_threshold(settings: Settings, count: int) -> NoneRaise UsageError if a bare run of count tests is too large.
No-op when the project declared stricttest_sandbox_required = false, when the run is already inside the sandbox, or when the run is a small targeted slice.
#enforce_tmp_outside_repo
def enforce_tmp_outside_repo(repo_root: Path, basetemp) -> NoneRefuse to run if the temp root is inside the repository.
Junk-commit incidents happen because a TMPDIR (or pytest basetemp) points inside the repo: fixtures create non-git directories there, and unanchored git commands walk UP into the real repo and commit junk. Fail loudly at startup rather than let that recur.