diff --git a/tests/feature/test_feature_base_dir.py b/tests/feature/test_feature_base_dir.py index bbbe97a18..8288161c2 100644 --- a/tests/feature/test_feature_base_dir.py +++ b/tests/feature/test_feature_base_dir.py @@ -1,8 +1,11 @@ """Test feature base dir.""" +import pkg_resources import pytest NOT_EXISTING_FEATURE_PATHS = [".", "/does/not/exist/"] +assert_outcomes_extra = pkg_resources.get_distribution("pytest").parsed_version >= pkg_resources.parse_version("7.0.0") + @pytest.mark.parametrize("base_dir", NOT_EXISTING_FEATURE_PATHS) def test_feature_path_not_found(testdir, base_dir): @@ -10,7 +13,10 @@ def test_feature_path_not_found(testdir, base_dir): prepare_testdir(testdir, base_dir) result = testdir.runpytest("-k", "test_not_found_by_ini") - result.assert_outcomes(passed=2) + if assert_outcomes_extra: + result.assert_outcomes(passed=2, deselected=8) + else: + result.assert_outcomes(passed=2) def test_feature_path_ok(testdir): @@ -18,7 +24,10 @@ def test_feature_path_ok(testdir): prepare_testdir(testdir, base_dir) result = testdir.runpytest("-k", "test_ok_by_ini") - result.assert_outcomes(passed=2) + if assert_outcomes_extra: + result.assert_outcomes(passed=2, deselected=8) + else: + result.assert_outcomes(passed=2) def test_feature_path_by_param_not_found(testdir): @@ -28,7 +37,10 @@ def test_feature_path_by_param_not_found(testdir): prepare_testdir(testdir, base_dir) result = testdir.runpytest("-k", "test_not_found_by_param") - result.assert_outcomes(passed=4) + if assert_outcomes_extra: + result.assert_outcomes(passed=4, deselected=6) + else: + result.assert_outcomes(passed=4) @pytest.mark.parametrize("base_dir", NOT_EXISTING_FEATURE_PATHS) @@ -38,7 +50,10 @@ def test_feature_path_by_param_ok(testdir, base_dir): prepare_testdir(testdir, base_dir) result = testdir.runpytest("-k", "test_ok_by_param") - result.assert_outcomes(passed=2) + if assert_outcomes_extra: + result.assert_outcomes(passed=2, deselected=8) + else: + result.assert_outcomes(passed=2) def prepare_testdir(testdir, ini_base_dir): diff --git a/tests/feature/test_steps.py b/tests/feature/test_steps.py index 1cb72b580..a397928d3 100644 --- a/tests/feature/test_steps.py +++ b/tests/feature/test_steps.py @@ -1,5 +1,9 @@ import textwrap +import pkg_resources + +assert_outcomes_extra = pkg_resources.get_distribution("pytest").parsed_version >= pkg_resources.parse_version("7.0.0") + def test_steps(testdir): testdir.makefile( @@ -466,22 +470,35 @@ def test_when_step_validation_error(): """ ) result = testdir.runpytest("-k test_when_fails_inline", "-vv") - result.assert_outcomes(failed=1) + if assert_outcomes_extra: + result.assert_outcomes(failed=1, deselected=3) + else: + result.assert_outcomes(failed=1) + result.stdout.fnmatch_lines(["*test_when_fails_inline*FAILED"]) assert "INTERNALERROR" not in result.stdout.str() result = testdir.runpytest("-k test_when_fails_decorated", "-vv") - result.assert_outcomes(failed=1) + if assert_outcomes_extra: + result.assert_outcomes(failed=1, deselected=3) + else: + result.assert_outcomes(failed=1) result.stdout.fnmatch_lines(["*test_when_fails_decorated*FAILED"]) assert "INTERNALERROR" not in result.stdout.str() result = testdir.runpytest("-k test_when_not_found", "-vv") - result.assert_outcomes(failed=1) + if assert_outcomes_extra: + result.assert_outcomes(failed=1, deselected=3) + else: + result.assert_outcomes(failed=1) result.stdout.fnmatch_lines(["*test_when_not_found*FAILED"]) assert "INTERNALERROR" not in result.stdout.str() result = testdir.runpytest("-k test_when_step_validation_error", "-vv") - result.assert_outcomes(failed=1) + if assert_outcomes_extra: + result.assert_outcomes(failed=1, deselected=3) + else: + result.assert_outcomes(failed=1) result.stdout.fnmatch_lines(["*test_when_step_validation_error*FAILED"]) assert "INTERNALERROR" not in result.stdout.str()