From a136111dcc0fb1b3663e1bc9fb740889b7df53c2 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 11 Jan 2020 23:04:43 +0100 Subject: [PATCH] tests: test_xfail_handling: use sys.dont_write_bytecode --- testing/test_stepwise.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/testing/test_stepwise.py b/testing/test_stepwise.py index 8d1b82f70..3bc77857d 100644 --- a/testing/test_stepwise.py +++ b/testing/test_stepwise.py @@ -167,11 +167,13 @@ def test_stop_on_collection_errors(broken_testdir, broken_first): result.stdout.fnmatch_lines("*error during collection*") -def test_xfail_handling(testdir): +def test_xfail_handling(testdir, monkeypatch): """Ensure normal xfail is ignored, and strict xfail interrupts the session in sw mode (#5547) """ + monkeypatch.setattr("sys.dont_write_bytecode", True) + contents = """ import pytest def test_a(): pass @@ -205,10 +207,6 @@ def test_xfail_handling(testdir): ] ) - # because we are writing to the same file, mtime might not be affected enough to - # invalidate the cache, making this next run flaky - if testdir.tmpdir.join("__pycache__").exists(): - testdir.tmpdir.join("__pycache__").remove() testdir.makepyfile(contents.format(assert_value="0", strict="True")) result = testdir.runpytest("--sw", "-v") result.stdout.fnmatch_lines(