Skip to content

Commit 262ed56

Browse files
tarpasblueyed
authored andcommitted
tests: clean up chmod-related tests to fix rm_rf warnings
Fixed #5974 (comment).
1 parent 0794289 commit 262ed56

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

testing/test_cacheprovider.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import shutil
3+
import stat
34
import sys
45
import textwrap
56

@@ -45,14 +46,17 @@ def test_cache_writefail_cachfile_silent(self, testdir):
4546
)
4647
def test_cache_writefail_permissions(self, testdir):
4748
testdir.makeini("[pytest]")
49+
mode = os.stat(testdir.tmpdir.ensure_dir(".pytest_cache"))[stat.ST_MODE]
4850
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
4951
config = testdir.parseconfigure()
5052
cache = config.cache
5153
cache.set("test/broken", [])
54+
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
5255

5356
@pytest.mark.skipif(sys.platform.startswith("win"), reason="no chmod on windows")
5457
@pytest.mark.filterwarnings("default")
5558
def test_cache_failure_warns(self, testdir):
59+
mode = os.stat(testdir.tmpdir.ensure_dir(".pytest_cache"))[stat.ST_MODE]
5660
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
5761
testdir.makepyfile(
5862
"""
@@ -62,6 +66,7 @@ def test_error():
6266
"""
6367
)
6468
result = testdir.runpytest("-rw")
69+
testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
6570
assert result.ret == 1
6671
# warnings from nodeids, lastfailed, and stepwise
6772
result.stdout.fnmatch_lines(["*could not create cache path*", "*3 warnings*"])

0 commit comments

Comments
 (0)