Skip to content

Commit 42eb7bc

Browse files
committed
Fix testing order, write environ var should fix CI
1 parent b876670 commit 42eb7bc

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

qtpy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def get_api_information(api_name):
297297

298298
# If a correct API name is passed to QT_API and it cannot be found,
299299
# switches to another and informs through the warning
300+
os.environ['QT_API'] = API
300301
if API_NAME != initial_api:
301302
if imported_api_list:
302303
# If the code is using QtPy is not supposed do directly import Qt api's,

qtpy/tests/test_main.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
2+
import importlib
23

3-
from qtpy import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
4+
from qtpy import QtCore, QtGui, QtWidgets, QtWebEngineWidgets, API
45

56

67
def assert_pyside():
@@ -52,7 +53,6 @@ def test_qt_api():
5253
"""
5354
If QT_API is specified, we check that the correct Qt wrapper was used
5455
"""
55-
5656
QT_API = os.environ.get('QT_API', '').lower()
5757

5858
if QT_API == 'pyside':
@@ -66,17 +66,28 @@ def test_qt_api():
6666
else:
6767
# If the tests are run locally, USE_QT_API and QT_API may not be
6868
# defined, but we still want to make sure qtpy is behaving sensibly.
69-
# We should then be loading, in order of decreasing preference, PyQt5,
70-
# PyQt4, and PySide.
69+
#
70+
# We should then be loading, in order of decreasing preference
71+
# matching the api_names[default_api='pyqt5'] in __init__.py
72+
# >>> PyQt5, PySide2, PyQt4, PySide
7173
try:
7274
import PyQt5
7375
except ImportError:
7476
try:
75-
import PyQt4
77+
import PySide2
7678
except ImportError:
77-
import PySide
78-
assert_pyside()
79+
try:
80+
import PyQt4
81+
except ImportError:
82+
try:
83+
import PySide
84+
except ImportError:
85+
pass
86+
else:
87+
assert_pyside()
88+
else:
89+
assert_pyqt4()
7990
else:
80-
assert_pyqt4()
91+
assert_pyside2()
8192
else:
8293
assert_pyqt5()

0 commit comments

Comments
 (0)