diff options
author | Ran Benita <ran@unusedvar.com> | 2020-11-09 11:45:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-09 11:45:38 +0200 |
commit | e986d84466dfa98dbbc55cc1bf5fcb99075f4ac3 (patch) | |
tree | f2e1e2e8afebad698ca7d6e19d16eb782dad987a /changelog | |
parent | 7aa5e49fc412b0675bd4d019d99613556469a2a5 (diff) | |
parent | 6f13d1b03b1e1af7def99505234075878407767d (diff) | |
download | pytest-e986d84466dfa98dbbc55cc1bf5fcb99075f4ac3.tar.gz |
Merge pull request #8006 from bluetech/export-MonkeyPatch
Export MonkeyPatch as pytest.MonkeyPatch
Diffstat (limited to 'changelog')
-rw-r--r-- | changelog/8006.feature.rst | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/changelog/8006.feature.rst b/changelog/8006.feature.rst new file mode 100644 index 000000000..0203689ba --- /dev/null +++ b/changelog/8006.feature.rst @@ -0,0 +1,8 @@ +It is now possible to construct a :class:`~pytest.MonkeyPatch` object directly as ``pytest.MonkeyPatch()``, +in cases when the :fixture:`monkeypatch` fixture cannot be used. Previously some users imported it +from the private `_pytest.monkeypatch.MonkeyPatch` namespace. + +Additionally, :meth:`MonkeyPatch.context <pytest.MonkeyPatch.context>` is now a classmethod, +and can be used as ``with MonkeyPatch.context() as mp: ...``. This is the recommended way to use +``MonkeyPatch`` directly, since unlike the ``monkeypatch`` fixture, an instance created directly +is not ``undo()``-ed automatically. |