From 94bdd18a035bfa49c784cc595573d2cfde4426c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 31 Jul 2020 20:13:24 +0200 Subject: [PATCH 1/3] Fix skipping test_config_initialization for pytest<5 Fix test_config_initialization to be correctly skipped on pytest<5, by explicitly checking pytest version (idea copied from test_looponfail_removed_test). The current conditions are insufficient -- the outer check wrongly assumes pytest>=5 will always be used on Python 3 (which is not true if you need the same version to support both Python 2 and Python 3), and the inner condition apparently wrongly assuming that invocation_params attribute is not present in pytest-4. --- changelog/566.bugfix | 1 + testing/acceptance_test.py | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 changelog/566.bugfix diff --git a/changelog/566.bugfix b/changelog/566.bugfix new file mode 100644 index 0000000..e0be4ae --- /dev/null +++ b/changelog/566.bugfix @@ -0,0 +1 @@ +Fix test_config_initialization not being skipped correctly on pytest-4 diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 77e8ce4..c21e079 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -2,6 +2,7 @@ import os import re import sys import textwrap +from pkg_resources import parse_version import py import pytest @@ -578,15 +579,11 @@ def test_fixture_teardown_failure(testdir): @pytest.mark.skipif( - sys.version_info[:2] == (2, 7), - reason="Only available in pytest 5.0+ (Python 3 only)", + parse_version(pytest.__version__) < parse_version("5"), + reason="Only available in pytest 5.0+", ) def test_config_initialization(testdir, monkeypatch, pytestconfig): """Ensure workers and master are initialized consistently. Integration test for #445""" - if not hasattr(pytestconfig, "invocation_params"): - pytest.skip( - "requires pytest >=5.1 (config has no attribute 'invocation_params')" - ) testdir.makepyfile( **{ "dir_a/test_foo.py": """ From bcfbf9f94b98faf0475191d344c3af5d473cfacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 31 Jul 2020 20:16:41 +0200 Subject: [PATCH 2/3] tox.ini: Extend testing to py39 --- .travis.yml | 2 ++ tox.ini | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 79afe10..be759da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,8 @@ jobs: env: TOXENV=py36-pytestlatest - python: "3.7" env: TOXENV=py37-pytestlatest + - python: "3.9-dev" + env: TOXENV=py39-pytestlatest - python: "3.8" env: TOXENV=py38-pytestmaster diff --git a/tox.ini b/tox.ini index 584d3ed..d532a2f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist= linting - py{35,36,37,38}-pytestlatest + py{35,36,37,38,39}-pytestlatest py38-pytestmaster [testenv] From 55838a126db4fb75dfa23f6db8dab5fed3c94931 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 5 Aug 2020 19:24:53 -0300 Subject: [PATCH 3/3] Remove unnecessary skipif and changelog --- changelog/566.bugfix | 1 - testing/acceptance_test.py | 6 ------ 2 files changed, 7 deletions(-) delete mode 100644 changelog/566.bugfix diff --git a/changelog/566.bugfix b/changelog/566.bugfix deleted file mode 100644 index e0be4ae..0000000 --- a/changelog/566.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix test_config_initialization not being skipped correctly on pytest-4 diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index c21e079..5b19ee6 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1,8 +1,6 @@ import os import re -import sys import textwrap -from pkg_resources import parse_version import py import pytest @@ -578,10 +576,6 @@ def test_fixture_teardown_failure(testdir): assert result.ret -@pytest.mark.skipif( - parse_version(pytest.__version__) < parse_version("5"), - reason="Only available in pytest 5.0+", -) def test_config_initialization(testdir, monkeypatch, pytestconfig): """Ensure workers and master are initialized consistently. Integration test for #445""" testdir.makepyfile(