MCPcopy
hub / github.com/pytest-dev/pytest / test_undo_class_descriptors_delattr

Function test_undo_class_descriptors_delattr

testing/test_monkeypatch.py:394–418  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

392
393
394def test_undo_class_descriptors_delattr() -> None:
395 class SampleParent:
396 @classmethod
397 def hello(_cls):
398 pass
399
400 @staticmethod
401 def world():
402 pass
403
404 class SampleChild(SampleParent):
405 pass
406
407 monkeypatch = MonkeyPatch()
408
409 original_hello = SampleChild.hello
410 original_world = SampleChild.world
411 monkeypatch.delattr(SampleParent, "hello")
412 monkeypatch.delattr(SampleParent, "world")
413 assert getattr(SampleParent, "hello", None) is None
414 assert getattr(SampleParent, "world", None) is None
415
416 monkeypatch.undo()
417 assert original_hello == SampleChild.hello
418 assert original_world == SampleChild.world
419
420
421def test_issue1338_name_resolving() -> None:

Callers

nothing calls this directly

Calls 3

delattrMethod · 0.95
undoMethod · 0.95
MonkeyPatchClass · 0.90

Tested by

no test coverage detected