MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_subclass_clear_cla

Function test_subclass_clear_cla

lib/matplotlib/tests/test_axes.py:568–616  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

566
567
568def test_subclass_clear_cla():
569 # Ensure that subclasses of Axes call cla/clear correctly.
570 # Note, we cannot use mocking here as we want to be sure that the
571 # superclass fallback does not recurse.
572
573 with pytest.warns(PendingDeprecationWarning,
574 match='Overriding `Axes.cla`'):
575 class ClaAxes(Axes):
576 def cla(self):
577 nonlocal called
578 called = True
579
580 with pytest.warns(PendingDeprecationWarning,
581 match='Overriding `Axes.cla`'):
582 class ClaSuperAxes(Axes):
583 def cla(self):
584 nonlocal called
585 called = True
586 super().cla()
587
588 class SubClaAxes(ClaAxes):
589 pass
590
591 class ClearAxes(Axes):
592 def clear(self):
593 nonlocal called
594 called = True
595
596 class ClearSuperAxes(Axes):
597 def clear(self):
598 nonlocal called
599 called = True
600 super().clear()
601
602 class SubClearAxes(ClearAxes):
603 pass
604
605 fig = Figure()
606 for axes_class in [ClaAxes, ClaSuperAxes, SubClaAxes,
607 ClearAxes, ClearSuperAxes, SubClearAxes]:
608 called = False
609 ax = axes_class(fig, [0, 0, 1, 1])
610 # Axes.__init__ has already called clear (which aliases to cla or is in
611 # the subclass).
612 assert called
613
614 called = False
615 ax.cla()
616 assert called
617
618
619def test_cla_not_redefined_internally():

Callers

nothing calls this directly

Calls 2

FigureClass · 0.90
claMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…