Skip to content

Commit b2d746b

Browse files
committed
TST: Make refcount tests more resilient to Python changes
Check the change of the refcount, instead of the absolute value, as suggested by @ngoldbaum.
1 parent 4af11e7 commit b2d746b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/matplotlib/tests/test_quiver.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ def test_quiver_memory_leak():
2626

2727
Q = draw_quiver(ax)
2828
ttX = Q.X
29+
orig_refcount = sys.getrefcount(ttX)
2930
Q.remove()
3031

3132
del Q
3233

33-
assert sys.getrefcount(ttX) == 2
34+
assert sys.getrefcount(ttX) < orig_refcount
3435

3536

3637
@pytest.mark.skipif(platform.python_implementation() != 'CPython',
@@ -43,9 +44,9 @@ def test_quiver_key_memory_leak():
4344
qk = ax.quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$',
4445
labelpos='W',
4546
fontproperties={'weight': 'bold'})
46-
assert sys.getrefcount(qk) == 3
47+
orig_refcount = sys.getrefcount(qk)
4748
qk.remove()
48-
assert sys.getrefcount(qk) == 2
49+
assert sys.getrefcount(qk) < orig_refcount
4950

5051

5152
def test_quiver_number_of_args():

0 commit comments

Comments
 (0)