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 04a0de8

Browse filesBrowse files
committed
Don't fail Qt tests if bindings not installed.
1 parent 2f47c6a commit 04a0de8
Copy full SHA for 04a0de8

File tree

Expand file treeCollapse file tree

2 files changed

+18
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-7
lines changed

‎lib/matplotlib/tests/test_backend_qt4.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_qt4.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77

88
import pytest
99

10-
with matplotlib.rc_context(rc={'backend': 'Qt4Agg'}):
11-
qt_compat = pytest.importorskip('matplotlib.backends.qt_compat')
10+
try:
11+
import PyQt4
12+
except (ImportError, RuntimeError): # RuntimeError if PyQt5 already imported.
13+
try:
14+
import PySide
15+
except ImportError:
16+
pytestmark = pytest.mark.skip("Failed to import a Qt4 binding.")
17+
18+
from matplotlib.backends.qt_compat import QtCore
1219
from matplotlib.backends.backend_qt4 import (
1320
MODIFIER_KEYS, SUPER, ALT, CTRL, SHIFT) # noqa
1421

15-
QtCore = qt_compat.QtCore
1622
_, ControlModifier, ControlKey = MODIFIER_KEYS[CTRL]
1723
_, AltModifier, AltKey = MODIFIER_KEYS[ALT]
1824
_, SuperModifier, SuperKey = MODIFIER_KEYS[SUPER]

‎lib/matplotlib/tests/test_backend_qt5.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_qt5.py
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77

88
import pytest
99

10-
with matplotlib.rc_context(rc={'backend': 'Qt5Agg'}):
11-
qt_compat = pytest.importorskip('matplotlib.backends.qt_compat',
12-
minversion='5')
10+
try:
11+
import PyQt5
12+
except (ImportError, RuntimeError): # RuntimeError if PyQt4 already imported.
13+
try:
14+
import PySide2
15+
except ImportError:
16+
pytestmark = pytest.mark.skip("Failed to import a Qt5 binding.")
17+
18+
from matplotlib.backends.qt_compat import QtCore
1319
from matplotlib.backends.backend_qt5 import (
1420
MODIFIER_KEYS, SUPER, ALT, CTRL, SHIFT) # noqa
1521

16-
QtCore = qt_compat.QtCore
1722
_, ControlModifier, ControlKey = MODIFIER_KEYS[CTRL]
1823
_, AltModifier, AltKey = MODIFIER_KEYS[ALT]
1924
_, SuperModifier, SuperKey = MODIFIER_KEYS[SUPER]

0 commit comments

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