Skip to content

Commit 520694c

Browse files
committed
TST: fix test for raise
1 parent 0cc8bc2 commit 520694c

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Incompatible layout engines raise
22
---------------------------------
3-
`tight_layout` and `constrained_layout` are incompatible if
3+
``tight_layout`` and ``constrained_layout`` are incompatible if
44
a colorbar has been added to the figure. Invoking the incompatible layout
55
engine used to warn, but now raises with a ``RuntimeError``.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
New ``layout_engine`` module
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
34
Matplotlib ships with ``tight_layout`` and ``constrained_layout`` layout
45
engines. A new ``layout_engine`` module is provided to allow downstream
5-
libraries to write their own layout engines and `.figure` objects can not take
6-
a `.LayoutEngine` subclass as an argument to the *layout* parameter.
6+
libraries to write their own layout engines and `~.Figure.figure` objects can
7+
not take a `.LayoutEngine` subclass as an argument to the *layout* parameter.

lib/matplotlib/tests/test_figure.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -610,18 +610,14 @@ def test_invalid_layouts():
610610
fig, ax = plt.subplots(layout="constrained")
611611
pc = ax.pcolormesh(np.random.randn(2, 2))
612612
fig.colorbar(pc)
613-
with pytest.warns(UserWarning, match='Colorbar layout of new layout'):
613+
with pytest.raises(RuntimeError, match='Colorbar layout of new layout'):
614614
fig.set_layout_engine("tight")
615-
# check that engine didn't change
616-
assert isinstance(fig.get_layout_engine(), ConstrainedLayoutEngine)
617615

618616
fig, ax = plt.subplots(layout="tight")
619617
pc = ax.pcolormesh(np.random.randn(2, 2))
620618
fig.colorbar(pc)
621-
with pytest.warns(UserWarning, match='Colorbar layout of new layout'):
619+
with pytest.raises(RuntimeError, match='Colorbar layout of new layout'):
622620
fig.set_layout_engine("constrained")
623-
# check that engine didn't change
624-
assert isinstance(fig.get_layout_engine(), TightLayoutEngine)
625621

626622

627623
@check_figures_equal(extensions=["png", "pdf"])
@@ -1039,8 +1035,6 @@ def test_subfigure():
10391035
sub[0].colorbar(pc, ax=axs)
10401036
sub[0].suptitle('Left Side')
10411037

1042-
dsadsa
1043-
10441038
axs = sub[1].subplots(1, 3)
10451039
for ax in axs.flat:
10461040
pc = ax.pcolormesh(np.random.randn(30, 30), vmin=-2, vmax=2)

0 commit comments

Comments
 (0)