From ff230121dd42bf5db87fce9e990af9dbab032bfb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 8 Feb 2017 13:45:56 +0100 Subject: [PATCH 1/4] Fix error message on invalid PYTEST_QT_API value It was this before: INTERNALERROR> RuntimeError: Invalid value for $PYTEST_QT_API: --- pytestqt/qt_compat.py | 2 +- tests/test_basics.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pytestqt/qt_compat.py b/pytestqt/qt_compat.py index 22f0bf88..796ebaaf 100644 --- a/pytestqt/qt_compat.py +++ b/pytestqt/qt_compat.py @@ -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 diff --git a/tests/test_basics.py b/tests/test_basics.py index 835c2fab..930b612d 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -353,3 +353,17 @@ def test_foo(qtbot): '*ImportError:*' ]) + +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']) From 562e694b56d6e47f6a8bb82c2fdb42d8b561dd97 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 8 Feb 2017 13:47:30 +0100 Subject: [PATCH 2/4] Fix tests on Python 3.6 --- tests/test_basics.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test_basics.py b/tests/test_basics.py index 930b612d..fddac5c3 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -349,9 +349,18 @@ 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): From a2d19086f4b57cbc92b38718a39788f9c6266c72 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 8 Feb 2017 13:47:53 +0100 Subject: [PATCH 3/4] Test Python 3.6 on Travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 526ddcc5..793f89e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ dist: trusty python: - "2.7" - "3.4" + - "3.6" virtualenv: system_site_packages: true From 9d7d2e7616ff468879d54e4985f6af8d7551743c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 8 Feb 2017 13:57:04 +0100 Subject: [PATCH 4/4] Remove Python 3.6 again on Travis Looks like it doesn't have a 3.6 with system-site-packages --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 793f89e0..526ddcc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ dist: trusty python: - "2.7" - "3.4" - - "3.6" virtualenv: system_site_packages: true