summaryrefslogtreecommitdiff
path: root/dev-python/pytest/files/pytest-5.0.1-test_xfail_rmdir.patch
blob: 5c6154cd92c0311c1aa747f3bd35b14525063351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From ab39502c98f40c03a2956dcf6c6b9daf5ee41a63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Fri, 26 Jul 2019 02:23:14 +0200
Subject: [PATCH] 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 https://github.com/pytest-dev/pytest/issues/5664
---
 changelog/5664.trivial.rst | 2 ++
 testing/test_stepwise.py   | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
 create mode 100644 changelog/5664.trivial.rst

diff --git a/changelog/5664.trivial.rst b/changelog/5664.trivial.rst
new file mode 100644
index 000000000..3928454ef
--- /dev/null
+++ b/changelog/5664.trivial.rst
@@ -0,0 +1,2 @@
+When invoking pytest's own testsuite with ``PYTHONDONTWRITEBYTECODE=1``,
+the ``test_xfail_handling`` test no longer fails.
diff --git a/testing/test_stepwise.py b/testing/test_stepwise.py
index 591d67b6c..f61425b6b 100644
--- a/testing/test_stepwise.py
+++ b/testing/test_stepwise.py
@@ -207,7 +207,8 @@ def test_d(): pass
 
     # because we are writing to the same file, mtime might not be affected enough to
     # invalidate the cache, making this next run flaky
-    testdir.tmpdir.join("__pycache__").remove()
+    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(