Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63207bb

Browse files
committed
TST: Use correct method of clearing mock objects
In Python 3.13.12 and 3.14.3, fixes for thread-safety of mock `call_count` meant that manually changing it no longer works [1]. Instead use the more correct `reset_mock` method. [1] python/cpython#142651 (comment)
1 parent c4b9963 commit 63207bb

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def _impl_test_interactive_timers():
669669
assert mock.call_count > 1
670670

671671
# Now turn it into a single shot timer and verify only one gets triggered
672-
mock.call_count = 0
672+
mock.reset_mock()
673673
timer.single_shot = True
674674
timer.start()
675675
plt.pause(pause_time)

lib/matplotlib/tests/test_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ def test_norm_callback():
16461646
assert increment.call_count == 2
16471647

16481648
# We only want autoscale() calls to send out one update signal
1649-
increment.call_count = 0
1649+
increment.reset_mock()
16501650
norm.autoscale([0, 1, 2])
16511651
assert increment.call_count == 1
16521652

0 commit comments

Comments
 (0)