@@ -8056,25 +8056,32 @@ def test_artist_sublists():
8056
8056
assert not ax .lines
8057
8057
assert not ax .tables
8058
8058
8059
+ # Adding items should warn.
8059
8060
with pytest .warns (MatplotlibDeprecationWarning ,
8060
8061
match = 'modification of the Axes.texts property' ):
8062
+ text ._figure = text ._axes = None
8061
8063
ax .texts .append (text )
8062
8064
with pytest .warns (MatplotlibDeprecationWarning ,
8063
8065
match = 'modification of the Axes.collections property' ):
8066
+ col ._figure = col ._axes = None
8064
8067
ax .collections .append (col )
8065
8068
with pytest .warns (MatplotlibDeprecationWarning ,
8066
8069
match = 'modification of the Axes.images property' ):
8070
+ im ._figure = im ._axes = None
8067
8071
ax .images .append (im )
8068
8072
with pytest .warns (MatplotlibDeprecationWarning ,
8069
8073
match = 'modification of the Axes.patches property' ):
8074
+ patch ._figure = patch ._axes = None
8070
8075
ax .patches .append (patch )
8071
8076
# verify things are back
8072
8077
assert list (ax .collections ) == [col ]
8073
8078
assert list (ax .images ) == [im ]
8074
8079
assert list (ax .patches ) == [patch ]
8075
8080
assert list (ax .texts ) == [text ]
8076
8081
8077
- # Adding items should warn.
8082
+ for ln in lines :
8083
+ ln ._figure = ln ._axes = None
8084
+
8078
8085
with pytest .warns (MatplotlibDeprecationWarning ,
8079
8086
match = 'modification of the Axes.lines property' ):
8080
8087
ax .lines .append (lines [- 2 ])
@@ -8091,6 +8098,10 @@ def test_artist_sublists():
8091
8098
# Modifying items should warn.
8092
8099
with pytest .warns (MatplotlibDeprecationWarning ,
8093
8100
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
8094
8105
ax .lines [0 ] = lines [0 ]
8095
8106
assert list (ax .lines ) == [lines [0 ], lines [- 2 ], lines [- 1 ]]
8096
8107
with pytest .warns (MatplotlibDeprecationWarning ,
0 commit comments