From 262ed567d065cf2455f988a60def75133a711345 Mon Sep 17 00:00:00 2001 From: Tibor Arpas Date: Tue, 5 Nov 2019 22:10:27 +0100 Subject: [PATCH] tests: clean up chmod-related tests to fix rm_rf warnings Fixed https://github.com/pytest-dev/pytest/issues/5974#issuecomment-549822509. --- testing/test_cacheprovider.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index dfc3c5320..6513909bc 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -1,5 +1,6 @@ import os import shutil +import stat import sys import textwrap @@ -45,14 +46,17 @@ class TestNewAPI: ) def test_cache_writefail_permissions(self, testdir): testdir.makeini("[pytest]") + mode = os.stat(testdir.tmpdir.ensure_dir(".pytest_cache"))[stat.ST_MODE] testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0) config = testdir.parseconfigure() cache = config.cache cache.set("test/broken", []) + testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode) @pytest.mark.skipif(sys.platform.startswith("win"), reason="no chmod on windows") @pytest.mark.filterwarnings("default") def test_cache_failure_warns(self, testdir): + mode = os.stat(testdir.tmpdir.ensure_dir(".pytest_cache"))[stat.ST_MODE] testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0) testdir.makepyfile( """ @@ -62,6 +66,7 @@ class TestNewAPI: """ ) result = testdir.runpytest("-rw") + testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode) assert result.ret == 1 # warnings from nodeids, lastfailed, and stepwise result.stdout.fnmatch_lines(["*could not create cache path*", "*3 warnings*"])