MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_delattr

Function test_delattr

testing/test_monkeypatch.py:93–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91
92
93def test_delattr() -> None:
94 class A:
95 x = 1
96
97 monkeypatch = MonkeyPatch()
98 monkeypatch.delattr(A, "x")
99 assert not hasattr(A, "x")
100 monkeypatch.undo()
101 assert A.x == 1
102
103 monkeypatch = MonkeyPatch()
104 monkeypatch.delattr(A, "x")
105 pytest.raises(AttributeError, monkeypatch.delattr, A, "y")
106 monkeypatch.delattr(A, "y", raising=False)
107 monkeypatch.setattr(A, "x", 5, raising=False)
108 assert A.x == 5
109 monkeypatch.undo()
110 assert A.x == 1
111
112
113def test_setitem() -> None:

Callers

nothing calls this directly

Calls 4

delattrMethod · 0.95
undoMethod · 0.95
setattrMethod · 0.95
MonkeyPatchClass · 0.90

Tested by

no test coverage detected