Skip to content

Commit

Permalink
Disable plugin autoloading in the test suite (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgorny authored Aug 24, 2023
1 parent fec7a49 commit 44432be
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,15 @@ def test_env(
Path(str(tmp_dir / f"test_{test_name}.py")).symlink_to(Path(__file__).parent / "template.py")
(tmp_dir / "pytest.ini").write_text(ini, encoding="utf-8")

new_env = {
**env,
"_TEST_ENV": repr(expected_env),
"PYTEST_DISABLE_PLUGIN_AUTOLOAD": "1",
"PYTEST_PLUGINS": "pytest_env.plugin",
}

# monkeypatch persists env variables across parametrized tests, therefore using mock.patch.dict
with mock.patch.dict(os.environ, {**env, "_TEST_ENV": repr(expected_env)}, clear=True):
with mock.patch.dict(os.environ, new_env, clear=True):
result = testdir.runpytest()

result.assert_outcomes(passed=1)

0 comments on commit 44432be

Please sign in to comment.