Skip to content

Commit ab39502

Browse files
committed
In test_xfail_handling, only remove __pycache__ if it exists
Previously, the test failed when the directory was not present, which could have been caused for example by invoking the tests with PYTHONDONTWRITEBYTECODE=1. Fixes #5664
1 parent 50c7b5d commit ab39502

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

changelog/5664.trivial.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
When invoking pytest's own testsuite with ``PYTHONDONTWRITEBYTECODE=1``,
2+
the ``test_xfail_handling`` test no longer fails.

testing/test_stepwise.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def test_d(): pass
207207

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

0 commit comments

Comments
 (0)