|
18 | 18 | from matplotlib.axes import Axes |
19 | 19 | from matplotlib.figure import Figure |
20 | 20 | from matplotlib.layout_engine import (ConstrainedLayoutEngine, |
21 | | - TightLayoutEngine) |
| 21 | + TightLayoutEngine, |
| 22 | + NullLayoutEnigne) |
22 | 23 | from matplotlib.ticker import AutoMinorLocator, FixedFormatter, ScalarFormatter |
23 | 24 | import matplotlib.pyplot as plt |
24 | 25 | import matplotlib.dates as mdates |
@@ -610,17 +611,23 @@ def test_invalid_layouts(): |
610 | 611 | fig, ax = plt.subplots(layout="constrained") |
611 | 612 | pc = ax.pcolormesh(np.random.randn(2, 2)) |
612 | 613 | fig.colorbar(pc) |
| 614 | + with pytest.raises(RuntimeError, match='Colorbar layout of new layout'): |
| 615 | + fig.set_layout_engine("tight") |
| 616 | + fig.set_layout_engine("none") |
613 | 617 | with pytest.raises(RuntimeError, match='Colorbar layout of new layout'): |
614 | 618 | fig.set_layout_engine("tight") |
615 | 619 |
|
616 | 620 | fig, ax = plt.subplots(layout="tight") |
617 | 621 | pc = ax.pcolormesh(np.random.randn(2, 2)) |
618 | 622 | fig.colorbar(pc) |
| 623 | + with pytest.raises(RuntimeError, match='Colorbar layout of new layout'): |
| 624 | + fig.set_layout_engine("constrained") |
| 625 | + fig.set_layout_engine("none") |
619 | 626 | with pytest.raises(RuntimeError, match='Colorbar layout of new layout'): |
620 | 627 | fig.set_layout_engine("constrained") |
621 | 628 |
|
622 | 629 | fig.set_layout_engine("none") |
623 | | - assert fig.get_layout_engine() is None |
| 630 | + assert isinstance(fig.get_layout_engine(), NullLayoutEnigne) |
624 | 631 |
|
625 | 632 |
|
626 | 633 | @check_figures_equal(extensions=["png", "pdf"]) |
|
0 commit comments