From eafc24a29f989cd104f7fac4f1c91d8bc3d08c63 Mon Sep 17 00:00:00 2001 From: Stuart Cook Date: Sat, 20 Feb 2021 15:24:22 +1100 Subject: [PATCH] Resolve pytest warnings about the deprecated --strict flag As of pytest 6.2, --strict is a deprecated alias for --strict-markers, which was renamed to reflect the flag's actual narrow behaviour. https://docs.pytest.org/en/stable/deprecations.html#the-strict-command-line-option --- hypothesis-python/tests/pytest/test_mark.py | 8 ++++++-- hypothesis-python/tests/pytest/test_seeding.py | 10 ++++++---- hypothesis-python/tests/pytest/test_skipping.py | 4 +++- hypothesis-python/tox.ini | 4 ++-- pytest.ini | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/hypothesis-python/tests/pytest/test_mark.py b/hypothesis-python/tests/pytest/test_mark.py index 2ee0fdcdf3..861d76b5af 100644 --- a/hypothesis-python/tests/pytest/test_mark.py +++ b/hypothesis-python/tests/pytest/test_mark.py @@ -31,7 +31,9 @@ def test_bar(): def test_can_select_mark(testdir): script = testdir.makepyfile(TESTSUITE) - result = testdir.runpytest(script, "--verbose", "--strict", "-m", "hypothesis") + result = testdir.runpytest( + script, "--verbose", "--strict-markers", "-m", "hypothesis" + ) out = "\n".join(result.stdout.lines) assert "1 passed, 1 deselected" in out @@ -53,6 +55,8 @@ def test_bar(self): def test_can_select_mark_on_unittest(testdir): script = testdir.makepyfile(UNITTEST_TESTSUITE) - result = testdir.runpytest(script, "--verbose", "--strict", "-m", "hypothesis") + result = testdir.runpytest( + script, "--verbose", "--strict-markers", "-m", "hypothesis" + ) out = "\n".join(result.stdout.lines) assert "1 passed, 1 deselected" in out diff --git a/hypothesis-python/tests/pytest/test_seeding.py b/hypothesis-python/tests/pytest/test_seeding.py index 26dab095e8..9f874c335c 100644 --- a/hypothesis-python/tests/pytest/test_seeding.py +++ b/hypothesis-python/tests/pytest/test_seeding.py @@ -48,7 +48,7 @@ def test_runs_repeatably_when_seed_is_set(seed, testdir): results = [ testdir.runpytest( - script, "--verbose", "--strict", "--hypothesis-seed", str(seed) + script, "--verbose", "--strict-markers", "--hypothesis-seed", str(seed) ) for _ in range(2) ] @@ -94,7 +94,7 @@ def test_repeats_healthcheck_when_following_seed_instruction(testdir, tmpdir): script = testdir.makepyfile(health_check_test) - initial = testdir.runpytest(script, "--verbose", "--strict") + initial = testdir.runpytest(script, "--verbose", "--strict-markers") match = CONTAINS_SEED_INSTRUCTION.search("\n".join(initial.stdout.lines)) initial_output = "\n".join(initial.stdout.lines) @@ -102,12 +102,14 @@ def test_repeats_healthcheck_when_following_seed_instruction(testdir, tmpdir): match = CONTAINS_SEED_INSTRUCTION.search(initial_output) assert match is not None - rerun = testdir.runpytest(script, "--verbose", "--strict", match.group(0)) + rerun = testdir.runpytest(script, "--verbose", "--strict-markers", match.group(0)) rerun_output = "\n".join(rerun.stdout.lines) assert "FailedHealthCheck" in rerun_output assert "--hypothesis-seed" not in rerun_output - rerun2 = testdir.runpytest(script, "--verbose", "--strict", "--hypothesis-seed=10") + rerun2 = testdir.runpytest( + script, "--verbose", "--strict-markers", "--hypothesis-seed=10" + ) rerun2_output = "\n".join(rerun2.stdout.lines) assert "FailedHealthCheck" not in rerun2_output diff --git a/hypothesis-python/tests/pytest/test_skipping.py b/hypothesis-python/tests/pytest/test_skipping.py index 622669df8b..dea9d0d4a5 100644 --- a/hypothesis-python/tests/pytest/test_skipping.py +++ b/hypothesis-python/tests/pytest/test_skipping.py @@ -45,6 +45,8 @@ def test_no_falsifying_example_if_pytest_skip(testdir): continue running the test and shrink process, nor should it print anything about falsifying examples.""" script = testdir.makepyfile(PYTEST_TESTSUITE) - result = testdir.runpytest(script, "--verbose", "--strict", "-m", "hypothesis") + result = testdir.runpytest( + script, "--verbose", "--strict-markers", "-m", "hypothesis" + ) out = "\n".join(result.stdout.lines) assert "Falsifying example" not in out diff --git a/hypothesis-python/tox.ini b/hypothesis-python/tox.ini index 8d4dfe20cf..4c5f07e5f1 100644 --- a/hypothesis-python/tox.ini +++ b/hypothesis-python/tox.ini @@ -92,7 +92,7 @@ commands = pip install .[zoneinfo] python -m coverage --version python -m coverage debug sys - python -m coverage run --rcfile=.coveragerc -m pytest -n0 --strict tests/cover tests/conjecture tests/datetime tests/numpy tests/pandas tests/lark --ff {posargs} + python -m coverage run --rcfile=.coveragerc -m pytest -n0 --strict-markers tests/cover tests/conjecture tests/datetime tests/numpy tests/pandas tests/lark --ff {posargs} python -m coverage report -m --fail-under=100 --show-missing --skip-covered python scripts/validate_branch_check.py @@ -106,7 +106,7 @@ whitelist_externals= setenv= HYPOTHESIS_INTERNAL_COVERAGE=true commands = - python -m coverage run --rcfile=.coveragerc --source=hypothesis.internal.conjecture -m pytest -n0 --strict tests/conjecture + python -m coverage run --rcfile=.coveragerc --source=hypothesis.internal.conjecture -m pytest -n0 --strict-markers tests/conjecture python -m coverage report -m --fail-under=100 --show-missing --skip-covered diff --git a/pytest.ini b/pytest.ini index 9c23e82af5..d2cd573f7b 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts=--strict --tb=native -p pytester --runpytest=subprocess --durations=20 +addopts=--strict-markers --tb=native -p pytester --runpytest=subprocess --durations=20 filterwarnings = ignore::hypothesis.errors.NonInteractiveExampleWarning