From f7b0ac503ec7339109b04abb5e03b4462a10f365 Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Wed, 29 Nov 2017 02:29:53 -0600 Subject: [PATCH 1/9] generate pytest envs with tox factors This eliminates all separate pytest envs in favor of conditionals in [testenv]. This requires renaming some environments to make the lack of certain functionality explicit: - instead of omitting pyqt{version}, use pyqtlink to use host PyQt tox.ini: eliminate -nocov It is possible to set the `PYTEST_ADDOPTS` environment variable to enable coverage checks, rather than a new command. --- tox.ini | 142 ++++++++++++++------------------------------------------ 1 file changed, 34 insertions(+), 108 deletions(-) diff --git a/tox.ini b/tox.ini index c0395a621..f805e006b 100644 --- a/tox.ini +++ b/tox.ini @@ -13,120 +13,24 @@ skipsdist = true setenv = QT_QPA_PLATFORM_PLUGIN_PATH={envdir}/Lib/site-packages/PyQt5/plugins/platforms PYTEST_QT_API=pyqt5 + pyqt{,56,571,58,59}: QUTE_BDD_WEBENGINE=true + cov: PYTEST_ADDOPTS=--cov --cov-report xml --cov-report=html --cov-report= passenv = PYTHON DISPLAY XAUTHORITY HOME USERNAME USER CI TRAVIS XDG_* QUTE_* DOCKER +basepython = + py35: python3.5 + py36: python3.6 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/misc/requirements/requirements-tests.txt + pyqt: PyQt5 + pyqt56: PyQt5==5.6 + pyqt571: PyQt5==5.7.1 + pyqt58: PyQt5==5.8.2 + pyqt59: PyQt5==5.9.2 commands = - {envpython} scripts/link_pyqt.py --tox {envdir} + pyqtlink: {envpython} scripts/link_pyqt.py --tox {envdir} {envpython} -bb -m pytest {posargs:tests} - -# test envs with PyQt5 from PyPI - -[testenv:py35-pyqt56] -basepython = python3.5 -setenv = - {[testenv]setenv} - QUTE_BDD_WEBENGINE=true -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - PyQt5==5.6 -commands = {envpython} -bb -m pytest {posargs:tests} - -[testenv:py35-pyqt571] -basepython = python3.5 -setenv = - {[testenv]setenv} - QUTE_BDD_WEBENGINE=true -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - PyQt5==5.7.1 -commands = {envpython} -bb -m pytest {posargs:tests} - -[testenv:py36-pyqt571] -basepython = python3.6 -setenv = - {[testenv]setenv} - QUTE_BDD_WEBENGINE=true -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - PyQt5==5.7.1 -commands = {envpython} -bb -m pytest {posargs:tests} - -[testenv:py35-pyqt58] -basepython = python3.5 -setenv = - {[testenv]setenv} - QUTE_BDD_WEBENGINE=true -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - PyQt5==5.8.2 -commands = {envpython} -bb -m pytest {posargs:tests} - -[testenv:py36-pyqt58] -basepython = {env:PYTHON:python3.6} -setenv = - {[testenv]setenv} - QUTE_BDD_WEBENGINE=true -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - PyQt5==5.8.2 -commands = {envpython} -bb -m pytest {posargs:tests} - -[testenv:py35-pyqt59] -basepython = python3.5 -setenv = - {[testenv]setenv} - QUTE_BDD_WEBENGINE=true -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - PyQt5==5.9.2 -commands = {envpython} -bb -m pytest {posargs:tests} - -[testenv:py36-pyqt59] -basepython = {env:PYTHON:python3.6} -setenv = - {[testenv]setenv} - QUTE_BDD_WEBENGINE=true -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - PyQt5==5.9.2 -commands = {envpython} -bb -m pytest {posargs:tests} - -# test envs with coverage - -[testenv:py35-pyqt59-cov] -basepython = python3.5 -setenv = - {[testenv]setenv} - QUTE_BDD_WEBENGINE=true -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - PyQt5==5.9.2 -commands = - {envpython} -bb -m pytest --cov --cov-report xml --cov-report=html --cov-report= {posargs:tests} - {envpython} scripts/dev/check_coverage.py {posargs} - -[testenv:py36-pyqt59-cov] -basepython = python3.6 -setenv = - {[testenv]setenv} - QUTE_BDD_WEBENGINE=true -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - PyQt5==5.9.2 -commands = - {envpython} -bb -m pytest --cov --cov-report xml --cov-report=html --cov-report= {posargs:tests} - {envpython} scripts/dev/check_coverage.py {posargs} + cov: {envpython} scripts/dev/check_coverage.py {posargs} # other envs @@ -196,6 +100,16 @@ setenv = PYTHONPATH={toxinidir} commands = {envpython} scripts/dev/run_vulture.py +[testenv:vulture-pyqtlink] +basepython = python3 +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/misc/requirements/requirements-vulture.txt +setenv = PYTHONPATH={toxinidir} +commands = + {envpython} scripts/link_pyqt.py --tox {envdir} + {envpython} scripts/dev/run_vulture.py + [testenv:pylint] basepython = {env:PYTHON:python3} ignore_errors = true @@ -208,6 +122,18 @@ commands = {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no {posargs} {envpython} scripts/dev/run_pylint_on_tests.py {toxinidir} --output-format=colorized --reports=no {posargs} +[testenv:pylint-pyqtlink] +basepython = {env:PYTHON:python3} +ignore_errors = true +passenv = +deps = + {[testenv]deps} + -r{toxinidir}/misc/requirements/requirements-pylint.txt +commands = + {envpython} scripts/link_pyqt.py --tox {envdir} + {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no {posargs} + {envpython} scripts/dev/run_pylint_on_tests.py {toxinidir} --output-format=colorized --reports=no {posargs} + [testenv:pylint-master] basepython = python3 passenv = {[testenv:pylint]passenv} From 2f231c86ac76cd47038759331b3a1b26418043e0 Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Thu, 30 Nov 2017 08:35:02 -0600 Subject: [PATCH 2/9] update tox env name in CI config Use py36-pyqtlink instead of py36 for macOS --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 65d917d73..e92df0b6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ matrix: - os: linux env: TESTENV=py36-pyqt59-cov - os: osx - env: TESTENV=py36 OSX=sierra + env: TESTENV=py36-pyqtlink OSX=sierra osx_image: xcode8.3 language: generic # https://github.com/qutebrowser/qutebrowser/issues/2013 From a5d0b9851ace4a3a335748925cc971b7f7407def Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Thu, 30 Nov 2017 14:14:11 -0600 Subject: [PATCH 3/9] tox.ini: remove pyqt5.6, use requirements-pyqt.txt --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index f805e006b..1c87d1a6c 100644 --- a/tox.ini +++ b/tox.ini @@ -22,8 +22,7 @@ basepython = deps = -r{toxinidir}/requirements.txt -r{toxinidir}/misc/requirements/requirements-tests.txt - pyqt: PyQt5 - pyqt56: PyQt5==5.6 + pyqt: -r{toxinidir}/misc/requirements/requirements-pyqt.txt pyqt571: PyQt5==5.7.1 pyqt58: PyQt5==5.8.2 pyqt59: PyQt5==5.9.2 From 6b762037809b9057774bb88f333466d6d1ba9bd3 Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Thu, 30 Nov 2017 14:21:37 -0600 Subject: [PATCH 4/9] update contributing.asciidoc with -pyqtlink envs --- doc/contributing.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc index afbb752c5..6f0b1bb72 100644 --- a/doc/contributing.asciidoc +++ b/doc/contributing.asciidoc @@ -97,7 +97,7 @@ unittests and several linters/checkers. Currently, the following tox environments are available: * Tests using https://www.pytest.org[pytest]: - - `py35`, `py36`: Run pytest for python 3.5/3.6 with the system-wide PyQt. + - `py35-pyqtlink`, `py36-pyqtlink`: Run pytest for python 3.5/3.6 with the system-wide PyQt. - `py36-pyqt57`, ..., `py36-pyqt59`: Run pytest with the given PyQt version (`py35-*` also works). - `py36-pyqt59-cov`: Run with coverage support (other Python/PyQt versions work too). * `flake8`: Run various linting checks via https://pypi.python.org/pypi/flake8[flake8]. From 49485ca220543ce9fbcc48da9f3b69feef695822 Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Thu, 30 Nov 2017 16:58:14 -0600 Subject: [PATCH 5/9] tox.ini: fix conditional syntax errors `{[testenv]deps}` was passing conditionals in their raw form; this simply lists them manually to avoid this. --- tox.ini | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index 1c87d1a6c..de41f2e0f 100644 --- a/tox.ini +++ b/tox.ini @@ -107,14 +107,15 @@ deps = setenv = PYTHONPATH={toxinidir} commands = {envpython} scripts/link_pyqt.py --tox {envdir} - {envpython} scripts/dev/run_vulture.py + {[testenv:vulture]commands} [testenv:pylint] basepython = {env:PYTHON:python3} ignore_errors = true passenv = deps = - {[testenv]deps} + -r{toxinidir}/requirements.txt + -r{toxinidir}/misc/requirements/requirements-tests.txt -r{toxinidir}/misc/requirements/requirements-pylint.txt -r{toxinidir}/misc/requirements/requirements-pyqt.txt commands = @@ -126,18 +127,19 @@ basepython = {env:PYTHON:python3} ignore_errors = true passenv = deps = - {[testenv]deps} + -r{toxinidir}/requirements.txt + -r{toxinidir}/misc/requirements/requirements-tests.txt -r{toxinidir}/misc/requirements/requirements-pylint.txt commands = {envpython} scripts/link_pyqt.py --tox {envdir} - {envpython} -m pylint scripts qutebrowser --output-format=colorized --reports=no {posargs} - {envpython} scripts/dev/run_pylint_on_tests.py {toxinidir} --output-format=colorized --reports=no {posargs} + {[testenv:pylint]commands} [testenv:pylint-master] basepython = python3 passenv = {[testenv:pylint]passenv} deps = - {[testenv]deps} + -r{toxinidir}/requirements.txt + -r{toxinidir}/misc/requirements/requirements-tests.txt -r{toxinidir}/misc/requirements/requirements-pylint-master.txt commands = {envpython} scripts/link_pyqt.py --tox {envdir} From df6ff55b7a34d543b9235bf71f0131b2598ff1c9 Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Fri, 1 Dec 2017 10:51:41 -0600 Subject: [PATCH 6/9] allow pytest to default to link_pyqt link_pyqt now checks for LINK_PYQT_SKIP, allowing pytest env names like `py36` to work properly without negative conditionals in tox.ini --- scripts/link_pyqt.py | 4 ++++ tox.ini | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/link_pyqt.py b/scripts/link_pyqt.py index 57eeb9138..82f8cbac5 100644 --- a/scripts/link_pyqt.py +++ b/scripts/link_pyqt.py @@ -205,6 +205,10 @@ def main(): args = parser.parse_args() if args.tox: + #workaround for the lack of negative factors in tox.ini + if 'LINK_PYQT_SKIP' in os.environ: + print('LINK_PYQT_SKIP set, exiting...') + sys.exit(0) executable = get_tox_syspython(args.path) else: executable = sys.executable diff --git a/tox.ini b/tox.ini index de41f2e0f..2ada5ab58 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ skipsdist = true setenv = QT_QPA_PLATFORM_PLUGIN_PATH={envdir}/Lib/site-packages/PyQt5/plugins/platforms PYTEST_QT_API=pyqt5 + pyqt{,56,571,58,59}: LINK_PYQT_SKIP=true pyqt{,56,571,58,59}: QUTE_BDD_WEBENGINE=true cov: PYTEST_ADDOPTS=--cov --cov-report xml --cov-report=html --cov-report= passenv = PYTHON DISPLAY XAUTHORITY HOME USERNAME USER CI TRAVIS XDG_* QUTE_* DOCKER @@ -27,7 +28,7 @@ deps = pyqt58: PyQt5==5.8.2 pyqt59: PyQt5==5.9.2 commands = - pyqtlink: {envpython} scripts/link_pyqt.py --tox {envdir} + {envpython} scripts/link_pyqt.py --tox {envdir} {envpython} -bb -m pytest {posargs:tests} cov: {envpython} scripts/dev/check_coverage.py {posargs} From 5607cc2be8c379c002dc257b3fd9a0d606ede98d Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Fri, 1 Dec 2017 10:52:58 -0600 Subject: [PATCH 7/9] Revert "update contributing.asciidoc with -pyqtlink envs" This reverts commit 6b762037809b9057774bb88f333466d6d1ba9bd3. --- doc/contributing.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc index 6f0b1bb72..afbb752c5 100644 --- a/doc/contributing.asciidoc +++ b/doc/contributing.asciidoc @@ -97,7 +97,7 @@ unittests and several linters/checkers. Currently, the following tox environments are available: * Tests using https://www.pytest.org[pytest]: - - `py35-pyqtlink`, `py36-pyqtlink`: Run pytest for python 3.5/3.6 with the system-wide PyQt. + - `py35`, `py36`: Run pytest for python 3.5/3.6 with the system-wide PyQt. - `py36-pyqt57`, ..., `py36-pyqt59`: Run pytest with the given PyQt version (`py35-*` also works). - `py36-pyqt59-cov`: Run with coverage support (other Python/PyQt versions work too). * `flake8`: Run various linting checks via https://pypi.python.org/pypi/flake8[flake8]. From fbd325f8d1a95507b656b3111b11d87d3e20aa1b Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Fri, 1 Dec 2017 10:55:08 -0600 Subject: [PATCH 8/9] Revert "update tox env name in CI config" This reverts commit 2f231c86ac76cd47038759331b3a1b26418043e0. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e92df0b6b..65d917d73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ matrix: - os: linux env: TESTENV=py36-pyqt59-cov - os: osx - env: TESTENV=py36-pyqtlink OSX=sierra + env: TESTENV=py36 OSX=sierra osx_image: xcode8.3 language: generic # https://github.com/qutebrowser/qutebrowser/issues/2013 From 38b2d42b4019d31febf298667041c6bbf6e6cd9e Mon Sep 17 00:00:00 2001 From: Ryan Farley Date: Sun, 3 Dec 2017 15:09:47 -0600 Subject: [PATCH 9/9] cleanup PYTEST_ADDOPTS for pytest subprocess See https://github.com/qutebrowser/qutebrowser/pull/3349 --- tests/unit/scripts/test_check_coverage.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/scripts/test_check_coverage.py b/tests/unit/scripts/test_check_coverage.py index 6b18568c5..d7183111f 100644 --- a/tests/unit/scripts/test_check_coverage.py +++ b/tests/unit/scripts/test_check_coverage.py @@ -50,6 +50,7 @@ class CovtestHelper: def run(self): """Run pytest with coverage for the given module.py.""" coveragerc = str(self._testdir.tmpdir / 'coveragerc') + self._monkeypatch.delenv('PYTEST_ADDOPTS', raising=False) return self._testdir.runpytest('--cov=module', '--cov-config={}'.format(coveragerc), '--cov-report=xml',