|
1 | 1 | importimportlib
|
| 2 | +fromunittest.mockimportpatch |
2 | 3 |
|
3 | 4 | frommatplotlibimportpath,transforms
|
4 | 5 | frommatplotlib.backend_basesimport (
|
5 | 6 | FigureCanvasBase,KeyEvent,LocationEvent,MouseButton,MouseEvent,
|
6 |
| -NavigationToolbar2,RendererBase) |
| 7 | +NavigationToolbar2,RendererBase,TimerBase) |
7 | 8 | frommatplotlib.backend_toolsimportRubberbandBase
|
8 | 9 | frommatplotlib.figureimportFigure
|
9 | 10 | frommatplotlib.testing._markersimportneeds_pgf_xelatex
|
@@ -581,3 +582,24 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis, forward_nav, t_s):
|
581 | 582 | # Check if twin-axes are properly triggered
|
582 | 583 | assertax_t.get_xlim()==pytest.approx(ax_t_twin.get_xlim(),abs=0.15)
|
583 | 584 | assertax_b.get_xlim()==pytest.approx(ax_b_twin.get_xlim(),abs=0.15)
|
| 585 | + |
| 586 | + |
| 587 | +deftest_timer_properties(): |
| 588 | +# Setting a property to the same value should not trigger the |
| 589 | +# private setter call again. |
| 590 | +timer=TimerBase(100) |
| 591 | +withpatch.object(timer,'_timer_set_interval')asmock: |
| 592 | +timer.interval=200 |
| 593 | +mock.assert_called_once() |
| 594 | +asserttimer.interval==200 |
| 595 | +timer.interval=200 |
| 596 | +# Make sure it wasn't called again |
| 597 | +mock.assert_called_once() |
| 598 | + |
| 599 | +withpatch.object(timer,'_timer_set_single_shot')asmock: |
| 600 | +timer.single_shot=True |
| 601 | +mock.assert_called_once() |
| 602 | +asserttimer._single |
| 603 | +timer.single_shot=True |
| 604 | +# Make sure it wasn't called again |
| 605 | +mock.assert_called_once() |