A convenient fixture for monkey-patching. The fixture provides these methods to modify objects, dictionaries or os.environ:: monkeypatch.setattr(obj, name, value, raising=True) monkeypatch.delattr(obj, name, raising=True) monkeypatch.setitem(mapping, name, value)
()
| 27 | |
| 28 | @fixture |
| 29 | def monkeypatch() -> Generator["MonkeyPatch", None, None]: |
| 30 | """A convenient fixture for monkey-patching. |
| 31 | |
| 32 | The fixture provides these methods to modify objects, dictionaries or |
| 33 | os.environ:: |
| 34 | |
| 35 | monkeypatch.setattr(obj, name, value, raising=True) |
| 36 | monkeypatch.delattr(obj, name, raising=True) |
| 37 | monkeypatch.setitem(mapping, name, value) |
| 38 | monkeypatch.delitem(obj, name, raising=True) |
| 39 | monkeypatch.setenv(name, value, prepend=None) |
| 40 | monkeypatch.delenv(name, raising=True) |
| 41 | monkeypatch.syspath_prepend(path) |
| 42 | monkeypatch.chdir(path) |
| 43 | |
| 44 | All modifications will be undone after the requesting test function or |
| 45 | fixture has finished. The ``raising`` parameter determines if a KeyError |
| 46 | or AttributeError will be raised if the set/deletion operation has no target. |
| 47 | """ |
| 48 | mpatch = MonkeyPatch() |
| 49 | yield mpatch |
| 50 | mpatch.undo() |
| 51 | |
| 52 | |
| 53 | def resolve(name: str) -> object: |
nothing calls this directly
no test coverage detected