@@ -14,18 +14,16 @@ environment variable, or to modify ``sys.path`` for importing.
1414The ``monkeypatch `` fixture provides these helper methods for safely patching and mocking
1515functionality in tests:
1616
17- .. code-block :: python
17+ * :meth: `monkeypatch.setattr(obj, name, value, raising=True) <pytest.MonkeyPatch.setattr> `
18+ * :meth: `monkeypatch.delattr(obj, name, raising=True) <pytest.MonkeyPatch.delattr> `
19+ * :meth: `monkeypatch.setitem(mapping, name, value) <pytest.MonkeyPatch.setitem> `
20+ * :meth: `monkeypatch.delitem(obj, name, raising=True) <pytest.MonkeyPatch.delitem> `
21+ * :meth: `monkeypatch.setenv(name, value, prepend=None) <pytest.MonkeyPatch.setenv> `
22+ * :meth: `monkeypatch.delenv(name, raising=True) <pytest.MonkeyPatch.delenv> `
23+ * :meth: `monkeypatch.syspath_prepend(path) <pytest.MonkeyPatch.syspath_prepend> `
24+ * :meth: `monkeypatch.chdir(path) <pytest.MonkeyPatch.chdir> `
25+ * :meth: `monkeypatch.context() <pytest.MonkeyPatch.context> `
1826
19- monkeypatch.setattr(obj, name, value, raising = True )
20- monkeypatch.setattr(" somemodule.obj.name" , value, raising = True )
21- monkeypatch.delattr(obj, name, raising = True )
22- monkeypatch.setitem(mapping, name, value)
23- monkeypatch.delitem(obj, name, raising = True )
24- monkeypatch.setenv(name, value, prepend = None )
25- monkeypatch.delenv(name, raising = True )
26- monkeypatch.syspath_prepend(path)
27- monkeypatch.chdir(path)
28- monkeypatch.context()
2927
3028All modifications will be undone after the requesting
3129test function or fixture has finished. The ``raising ``
@@ -64,8 +62,8 @@ and a discussion of its motivation.
6462
6563.. _`monkeypatch blog post` : https://tetamap.wordpress.com//2009/03/03/monkeypatching-in-unit-tests-done-right/
6664
67- Simple example: monkeypatching functions
68- ----------------------------------------
65+ Monkeypatching functions
66+ ------------------------
6967
7068Consider a scenario where you are working with user directories. In the context of
7169testing, you do not want your test to depend on the running user. ``monkeypatch ``
0 commit comments