Make sure `monkeypatch.undo()` is always called

This commit is contained in:
Sviatoslav Sydorenko 2022-08-05 23:51:18 +02:00
parent 6e7dc8bac8
commit 303b6e32ea
No known key found for this signature in database
GPG Key ID: 9345E8FEA89CA455
1 changed files with 2 additions and 3 deletions

View File

@ -45,9 +45,8 @@ def monkeypatch() -> Generator["MonkeyPatch", None, None]:
fixture has finished. The ``raising`` parameter determines if a KeyError
or AttributeError will be raised if the set/deletion operation has no target.
"""
mpatch = MonkeyPatch()
yield mpatch
mpatch.undo()
with MonkeyPatch.context() as mpatch:
yield mpatch
def resolve(name: str) -> object: