Expand description
Integration-test lints (issue #19; rules #48–#52) — the integration lint
command.
A lint here is a deterministic style/mechanism check on test code, as
opposed to the structural colocated-test / coverage rules. This module hosts
the mocking mechanism & style lints; more lints will join them under the
same command.
Detection is AST-based: each Python test file is parsed with
rustpython_parser and the tree is walked with a Visitor.
Implemented lints:
no-monkeypatch(#49): a test/fixture function that declares themonkeypatchparameter (pytest’s fixture). Patch withunittest.mockwrapped in apytest.fixtureinstead.no-inline-patch(#50): apatch(...)/patch.object(...)/patch.dict(...)call inside a test body — thewith patch(...)form or a bare call. Patches belong in apytest.fixture; a patch inside a fixture is allowed.no-environ-mutation(#51): direct mutation ofos.environ—os.environ[...] = …,del os.environ[...], or a mutating method (update/pop/setdefault/clear/popitem). Set env viapatch.dict(os.environ, {...})instead.no-constant-patch(#52): patching a module-global UPPER_CASE constant, e.g.patch("pkg.config.CACHE_DIR", …). Inject config explicitly. Waivable per file via the configexemptlist.
Structs§
- Violation
- A single lint violation found in a test file.
Functions§
- find_
violations - Scan the Python test files under
rootand return every lint violation, sorted by(file, line)for deterministic output.