Skip to main content

Module lint

Module lint 

Source
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 the monkeypatch parameter (pytest’s fixture). Patch with unittest.mock wrapped in a pytest.fixture instead.
  • no-inline-patch (#50): a patch(...) / patch.object(...) / patch.dict(...) call inside a test body — the with patch(...) form or a bare call. Patches belong in a pytest.fixture; a patch inside a fixture is allowed.
  • no-environ-mutation (#51): direct mutation of os.environos.environ[...] = …, del os.environ[...], or a mutating method (update / pop / setdefault / clear / popitem). Set env via patch.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 config exempt list.

Re-exports§

pub use crate::violation::Violation;

Functions§

find_violations
Scan the Python test files under root and return every lint violation, sorted by (file, line) for deterministic output.