Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pytestqt/qt_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _get_qt_api_from_env(self):
api = api.lower()
if api not in ('pyside', 'pyqt4', 'pyqt4v2', 'pyqt5'): # pragma: no cover
msg = 'Invalid value for $PYTEST_QT_API: %s'
raise RuntimeError(msg % qt_api)
raise RuntimeError(msg % api)
return api

def _guess_qt_api(self): # pragma: no cover
Expand Down
29 changes: 26 additions & 3 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,30 @@ def test_foo(qtbot):
'* 1 passed in *'
])
else:
result.stderr.fnmatch_lines([
'*ImportError:*'
])
try:
ModuleNotFoundError
except NameError:
# Python < 3.6
result.stderr.fnmatch_lines([
'*ImportError:*'
])
else:
# Python >= 3.6
result.stderr.fnmatch_lines([
'*ModuleNotFoundError:*'
])


def test_invalid_qt_api_envvar(testdir, monkeypatch):
"""
Make sure the error message with an invalid PYQTEST_QT_API is correct.
"""
testdir.makepyfile('''
import pytest

def test_foo(qtbot):
pass
''')
monkeypatch.setenv('PYTEST_QT_API', 'piecute')
result = testdir.runpytest_subprocess()
result.stderr.fnmatch_lines(['* Invalid value for $PYTEST_QT_API: piecute'])