Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit df7fe30

Browse filesBrowse files
committed
TST: Make the ArtistList tests work again
This test relies and removing and re-adding Artists from the same figure / axes repeatedly to make sure that the correct warnings come out. Took the lazy-route of working around the validation rather than making new Artists to add.
1 parent cbde096 commit df7fe30
Copy full SHA for df7fe30

File tree

1 file changed

+12
-1
lines changed
Filter options

1 file changed

+12
-1
lines changed

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8056,25 +8056,32 @@ def test_artist_sublists():
80568056
assert not ax.lines
80578057
assert not ax.tables
80588058

8059+
# Adding items should warn.
80598060
with pytest.warns(MatplotlibDeprecationWarning,
80608061
match='modification of the Axes.texts property'):
8062+
text._figure = text._axes = None
80618063
ax.texts.append(text)
80628064
with pytest.warns(MatplotlibDeprecationWarning,
80638065
match='modification of the Axes.collections property'):
8066+
col._figure = col._axes = None
80648067
ax.collections.append(col)
80658068
with pytest.warns(MatplotlibDeprecationWarning,
80668069
match='modification of the Axes.images property'):
8070+
im._figure = im._axes = None
80678071
ax.images.append(im)
80688072
with pytest.warns(MatplotlibDeprecationWarning,
80698073
match='modification of the Axes.patches property'):
8074+
patch._figure = patch._axes = None
80708075
ax.patches.append(patch)
80718076
# verify things are back
80728077
assert list(ax.collections) == [col]
80738078
assert list(ax.images) == [im]
80748079
assert list(ax.patches) == [patch]
80758080
assert list(ax.texts) == [text]
80768081

8077-
# Adding items should warn.
8082+
for ln in lines:
8083+
ln._figure = ln._axes = None
8084+
80788085
with pytest.warns(MatplotlibDeprecationWarning,
80798086
match='modification of the Axes.lines property'):
80808087
ax.lines.append(lines[-2])
@@ -8091,6 +8098,10 @@ def test_artist_sublists():
80918098
# Modifying items should warn.
80928099
with pytest.warns(MatplotlibDeprecationWarning,
80938100
match='modification of the Axes.lines property'):
8101+
ax.lines[0] = mpl.lines.Line2D([], [])
8102+
with pytest.warns(MatplotlibDeprecationWarning,
8103+
match='modification of the Axes.lines property'):
8104+
lines[0]._axes = lines[0]._figure = None
80948105
ax.lines[0] = lines[0]
80958106
assert list(ax.lines) == [lines[0], lines[-2], lines[-1]]
80968107
with pytest.warns(MatplotlibDeprecationWarning,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.