From f2bd3835acacaf580a48f63df5a0162869b0265c Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 27 Mar 2020 15:24:59 +0100 Subject: [PATCH] Add tests for toolmanager. ... and fix Help tool for tk (it needs a gif icon, generated (like the other gifs) with `convert -antialias -geometry 24x24 help.svg help.gif`). ... and also edit the matplotlibrc template to mention its availability. --- lib/matplotlib/backend_tools.py | 2 +- lib/matplotlib/mpl-data/images/help.gif | Bin 0 -> 564 bytes lib/matplotlib/tests/test_backends_interactive.py | 12 ++++++++++-- matplotlibrc.template | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 lib/matplotlib/mpl-data/images/help.gif diff --git a/lib/matplotlib/backend_tools.py b/lib/matplotlib/backend_tools.py index a27e364a4eb2..b9e4674c1f64 100644 --- a/lib/matplotlib/backend_tools.py +++ b/lib/matplotlib/backend_tools.py @@ -992,7 +992,7 @@ def _mouse_move(self, event): class ToolHelpBase(ToolBase): description = 'Print tool list, shortcuts and description' default_keymap = mpl.rcParams['keymap.help'] - image = 'help.png' + image = 'help' @staticmethod def format_shortcut(key_sequence): diff --git a/lib/matplotlib/mpl-data/images/help.gif b/lib/matplotlib/mpl-data/images/help.gif new file mode 100644 index 0000000000000000000000000000000000000000..614fa617ed4fe0b99ca3e5bd1f1018a1b4599c1f GIT binary patch literal 564 zcmZ?wbhEHblwgox_{IPNjEs!T%*^cU>|9)2+}zy!{QN>fLc+qr;^N{83JOX}N-8QU z8X6ipIywdh21Z6kmX?-QR#rAPHnz65etv!d0Rd4_Q86(w$;rtnDJj|6*}1v7`T6+; z1qFqLg(W2=m6es%)zvjMHI0ppZEbCxot=Gsef|CYlO|1?I(6!d88c?hnl*Rs+>IMI zZrZeI^XAQa_wL=lfB(UQ2ag^-diLzubLY;TKY#w_&6~Gx-+uV;;p4}TU%q_#>eZ{) zuV24;^X9{c51&7O{`vFguV24@|Ni~w&!2z){{8>|AMCRsKq&rX0lQKMM1takfqi0w zdsA~uYg>CqXIFPmZ(o16y|t~&1a}t$34U%qaf7M74zjEaOP8|BJM_3HEL*o!X+ftc z`!aq}-esJo-41G7rKea5Ez|8aP_l1w5nHA+&2sTlc9RJPJnLjP^_X(+Qd!lnyo|?i zn!D^$X0_+;rdnD$)^9b1ghUM9N-ooQEA{8C9gjx9gPS{L4U^8ixOgs5fx#L8yP>F~ literal 0 HcmV?d00001 diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index fabe9878e5fd..e5a6946e2211 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -1,5 +1,6 @@ import importlib import importlib.util +import json import os import signal import subprocess @@ -60,6 +61,7 @@ def _get_testable_interactive_backends(): _test_script = """\ import importlib import importlib.util +import json import sys from unittest import TestCase @@ -70,6 +72,8 @@ def _get_testable_interactive_backends(): "webagg.open_in_browser": False, "webagg.port_retries": 1, }) +if len(sys.argv) >= 2: # Second argument is json-encoded rcParams. + rcParams.update(json.loads(sys.argv[1])) backend = plt.rcParams["backend"].lower() assert_equal = TestCase().assertEqual assert_raises = TestCase().assertRaises @@ -122,10 +126,14 @@ def check_alt_backend(alt_backend): @pytest.mark.parametrize("backend", _get_testable_interactive_backends()) +@pytest.mark.parametrize("toolbar", ["toolbar2", "toolmanager"]) @pytest.mark.flaky(reruns=3) -def test_interactive_backend(backend): +def test_interactive_backend(backend, toolbar): + if backend == "macosx" and toolbar == "toolmanager": + pytest.skip("toolmanager is not implemented for macosx.") proc = subprocess.run( - [sys.executable, "-c", _test_script], + [sys.executable, "-c", _test_script, + json.dumps({"toolbar": toolbar})], env={**os.environ, "MPLBACKEND": backend}, timeout=_test_timeout, stdout=subprocess.PIPE, universal_newlines=True) if proc.returncode: diff --git a/matplotlibrc.template b/matplotlibrc.template index 2596a67f309b..72de3493db02 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -92,7 +92,7 @@ #backend_fallback: True #interactive: False -#toolbar: toolbar2 # {None, toolbar2} +#toolbar: toolbar2 # {None, toolbar2, toolmanager} #timezone: UTC # a pytz timezone string, e.g., US/Central or Europe/Paris