diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-02-05 00:39:29 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-02-05 00:39:29 +0900 |
commit | 1fc7bc6b1e0790532f13a9c17bea9e0aec00b79c (patch) | |
tree | 2348cd23bb5f1bb69540d109b42a0c375ac311c4 /sphinx/testing | |
parent | 32257ee524ff33bb2ad623ed595346b986113a87 (diff) | |
download | sphinx-git-1fc7bc6b1e0790532f13a9c17bea9e0aec00b79c.tar.gz |
test: change permissions of testfiles only $SPHINX_READONLY_TESTDIR set
Diffstat (limited to 'sphinx/testing')
-rw-r--r-- | sphinx/testing/path.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sphinx/testing/path.py b/sphinx/testing/path.py index c6e47dc3c..7707a4525 100644 --- a/sphinx/testing/path.py +++ b/sphinx/testing/path.py @@ -109,15 +109,16 @@ class path(str): pointed to by the symbolic links are copied. """ shutil.copytree(self, destination, symlinks=symlinks) - # If source tree is marked read-only (e.g. because it is on a read-only - # filesystem), `shutil.copytree` will mark the destination as read-only - # as well. To avoid failures when adding additional files/directories - # to the destination tree, ensure destination directories are not marked - # read-only. - for root, dirs, files in os.walk(destination): - os.chmod(root, 0o755 & ~UMASK) - for name in files: - os.chmod(os.path.join(root, name), 0o644 & ~UMASK) + if os.environ.get('SPHINX_READONLY_TESTDIR'): + # If source tree is marked read-only (e.g. because it is on a read-only + # filesystem), `shutil.copytree` will mark the destination as read-only + # as well. To avoid failures when adding additional files/directories + # to the destination tree, ensure destination directories are not marked + # read-only. + for root, dirs, files in os.walk(destination): + os.chmod(root, 0o755 & ~UMASK) + for name in files: + os.chmod(os.path.join(root, name), 0o644 & ~UMASK) def movetree(self, destination: str) -> None: """ |