Skip to content

Commit 064c10e

Browse files
committed
TST: Fix tight layout tests without text
If we pass `remove_text` to `image_comparison`, we don't expect tests to change from FreeType. But if `tight_layout` is called *before* the end of the test function, the layout will happen with the text that was supposed to be removed.
1 parent 3bef39e commit 064c10e

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed
Loading

Diff for: lib/matplotlib/tests/test_table.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ def test_label_colours():
8787
loc='best')
8888

8989

90-
@image_comparison(['table_cell_manipulation.png'], remove_text=True)
91-
def test_diff_cell_table():
90+
@image_comparison(['table_cell_manipulation.png'])
91+
def test_diff_cell_table(_text_placeholders):
9292
cells = ('horizontal', 'vertical', 'open', 'closed', 'T', 'R', 'B', 'L')
9393
cellText = [['1'] * len(cells)] * 2
9494
colWidths = [0.1] * len(cells)
9595

96-
_, axs = plt.subplots(nrows=len(cells), figsize=(4, len(cells)+1))
96+
_, axs = plt.subplots(nrows=len(cells), figsize=(4, len(cells)+1), layout='tight')
9797
for ax, cell in zip(axs, cells):
9898
ax.table(
9999
colWidths=colWidths,
@@ -102,7 +102,6 @@ def test_diff_cell_table():
102102
edges=cell,
103103
)
104104
ax.axis('off')
105-
plt.tight_layout()
106105

107106

108107
def test_customcell():
Loading

Diff for: lib/mpl_toolkits/axisartist/tests/test_axislines.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_axisline_style_size_color():
119119
@image_comparison(['axisline_style_tight.png'], remove_text=True,
120120
style='mpl20')
121121
def test_axisline_style_tight():
122-
fig = plt.figure(figsize=(2, 2))
122+
fig = plt.figure(figsize=(2, 2), layout='tight')
123123
ax = fig.add_subplot(axes_class=AxesZero)
124124
ax.axis["xzero"].set_axisline_style("-|>", size=5, facecolor='g')
125125
ax.axis["xzero"].set_visible(True)
@@ -129,8 +129,6 @@ def test_axisline_style_tight():
129129
for direction in ("left", "right", "bottom", "top"):
130130
ax.axis[direction].set_visible(False)
131131

132-
fig.tight_layout()
133-
134132

135133
@image_comparison(['subplotzero_ylabel.png'], style='mpl20')
136134
def test_subplotzero_ylabel():

0 commit comments

Comments
 (0)