Skip to content

TST: be more explicit about identifying qt4/qt5 imports #14139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/matplotlib/tests/test_backend_qt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import sys
from unittest import mock

import matplotlib
Expand Down Expand Up @@ -26,6 +27,8 @@ def mpl_test_settings(qt_module, mpl_test_settings):
def qt_module(request):
backend, = request.node.get_closest_marker('backend').args
if backend == 'Qt4Agg':
if any(k in sys.modules for k in ('PyQt5', 'PySide2')):
pytest.skip('Qt5 binding already imported')
try:
import PyQt4
# RuntimeError if PyQt5 already imported.
Expand All @@ -35,6 +38,8 @@ def qt_module(request):
except ImportError:
pytest.skip("Failed to import a Qt4 binding.")
elif backend == 'Qt5Agg':
if any(k in sys.modules for k in ('PyQt4', 'PySide')):
pytest.skip('Qt4 binding already imported')
try:
import PyQt5
# RuntimeError if PyQt4 already imported.
Expand Down