Skip to content

Commit

Permalink
Add tests for toolmanager.
Browse files Browse the repository at this point in the history
... 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.
  • Loading branch information
anntzer committed Apr 15, 2020
1 parent e39c67b commit f2bd383
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/matplotlib/backend_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Binary file added lib/matplotlib/mpl-data/images/help.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions lib/matplotlib/tests/test_backends_interactive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib
import importlib.util
import json
import os
import signal
import subprocess
Expand Down Expand Up @@ -60,6 +61,7 @@ def _get_testable_interactive_backends():
_test_script = """\
import importlib
import importlib.util
import json
import sys
from unittest import TestCase
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit f2bd383

Please sign in to comment.