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 2be06d4

Browse filesBrowse files
committed
TST: Add backend bases test
1 parent 9d7343c commit 2be06d4
Copy full SHA for 2be06d4

File tree

1 file changed

+23
-1
lines changed
Filter options

1 file changed

+23
-1
lines changed

‎lib/matplotlib/tests/test_backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_bases.py
+23-1Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import importlib
2+
from unittest.mock import patch
23

34
from matplotlib import path, transforms
45
from matplotlib.backend_bases import (
56
FigureCanvasBase, KeyEvent, LocationEvent, MouseButton, MouseEvent,
6-
NavigationToolbar2, RendererBase)
7+
NavigationToolbar2, RendererBase, TimerBase)
78
from matplotlib.backend_tools import RubberbandBase
89
from matplotlib.figure import Figure
910
from matplotlib.testing._markers import needs_pgf_xelatex
@@ -581,3 +582,24 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis, forward_nav, t_s):
581582
# Check if twin-axes are properly triggered
582583
assert ax_t.get_xlim() == pytest.approx(ax_t_twin.get_xlim(), abs=0.15)
583584
assert ax_b.get_xlim() == pytest.approx(ax_b_twin.get_xlim(), abs=0.15)
585+
586+
587+
def test_timer_properties():
588+
# Setting a property to the same value should not trigger the
589+
# private setter call again.
590+
timer = TimerBase(100)
591+
with patch.object(timer, '_timer_set_interval') as mock:
592+
timer.interval = 200
593+
mock.assert_called_once()
594+
assert timer.interval == 200
595+
timer.interval = 200
596+
# Make sure it wasn't called again
597+
mock.assert_called_once()
598+
599+
with patch.object(timer, '_timer_set_single_shot') as mock:
600+
timer.single_shot = True
601+
mock.assert_called_once()
602+
assert timer._single
603+
timer.single_shot = True
604+
# Make sure it wasn't called again
605+
mock.assert_called_once()

0 commit comments

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