Skip to content

Commit d7f27c4

Browse files
authored
Merge pull request #10144 from pytest-dev/backport-10143-to-7.1.x
2 parents 6f8c4fa + 7133c54 commit d7f27c4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc/en/how-to/monkeypatch.rst

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ functionality in tests:
2525
monkeypatch.delenv(name, raising=True)
2626
monkeypatch.syspath_prepend(path)
2727
monkeypatch.chdir(path)
28+
monkeypatch.context()
2829
2930
All modifications will be undone after the requesting
3031
test function or fixture has finished. The ``raising``
@@ -55,6 +56,9 @@ during a test.
5556
5. Use :py:meth:`monkeypatch.syspath_prepend <MonkeyPatch.syspath_prepend>` to modify ``sys.path`` which will also
5657
call ``pkg_resources.fixup_namespace_packages`` and :py:func:`importlib.invalidate_caches`.
5758

59+
6. Use :py:meth:`monkeypatch.context <MonkeyPatch.context>` to apply patches only in a specific scope, which can help
60+
control teardown of complex fixtures or patches to the stdlib.
61+
5862
See the `monkeypatch blog post`_ for some introduction material
5963
and a discussion of its motivation.
6064

0 commit comments

Comments
 (0)