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

Function test_undo_class_descriptors_delattr

testing/test_monkeypatch.py:365–389  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

363
364
365def test_undo_class_descriptors_delattr() -> None:
366 class SampleParent:
367 @classmethod
368 def hello(_cls):
369 pass
370
371 @staticmethod
372 def world():
373 pass
374
375 class SampleChild(SampleParent):
376 pass
377
378 monkeypatch = MonkeyPatch()
379
380 original_hello = SampleChild.hello
381 original_world = SampleChild.world
382 monkeypatch.delattr(SampleParent, "hello")
383 monkeypatch.delattr(SampleParent, "world")
384 assert getattr(SampleParent, "hello", None) is None
385 assert getattr(SampleParent, "world", None) is None
386
387 monkeypatch.undo()
388 assert original_hello == SampleChild.hello
389 assert original_world == SampleChild.world
390
391
392def 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