Skip to content

Commit a136111

Browse files
committed
tests: test_xfail_handling: use sys.dont_write_bytecode
1 parent 622995a commit a136111

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

testing/test_stepwise.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,13 @@ def test_stop_on_collection_errors(broken_testdir, broken_first):
167167
result.stdout.fnmatch_lines("*error during collection*")
168168

169169

170-
def test_xfail_handling(testdir):
170+
def test_xfail_handling(testdir, monkeypatch):
171171
"""Ensure normal xfail is ignored, and strict xfail interrupts the session in sw mode
172172
173173
(#5547)
174174
"""
175+
monkeypatch.setattr("sys.dont_write_bytecode", True)
176+
175177
contents = """
176178
import pytest
177179
def test_a(): pass
@@ -205,10 +207,6 @@ def test_d(): pass
205207
]
206208
)
207209

208-
# because we are writing to the same file, mtime might not be affected enough to
209-
# invalidate the cache, making this next run flaky
210-
if testdir.tmpdir.join("__pycache__").exists():
211-
testdir.tmpdir.join("__pycache__").remove()
212210
testdir.makepyfile(contents.format(assert_value="0", strict="True"))
213211
result = testdir.runpytest("--sw", "-v")
214212
result.stdout.fnmatch_lines(

0 commit comments

Comments
 (0)