aboutsummaryrefslogtreecommitdiff
path: root/pyfakefs/tests/test_utils.py
diff options
context:
space:
mode:
authormrbean-bremen <hansemrbean@googlemail.com>2022-10-03 13:08:21 +0200
committermrbean-bremen <mrbean-bremen@users.noreply.github.com>2022-10-04 19:03:27 +0200
commit28fbf1cefa221607c84c744bb6b669b25f87444d (patch)
tree4fd85fbb2b0f4ff98d0b9a6e98e2c3276ca69fa5 /pyfakefs/tests/test_utils.py
parent0fb50dd162f87121431540b9f962bcdda647013f (diff)
downloadpyfakefs-28fbf1cefa221607c84c744bb6b669b25f87444d.tar.gz
Fix handling of read permissionsupstream-master
- rmdir and chmod work without permission if the file user ID is the current user ID - better handle owner/group/other permission bits - fixes #719
Diffstat (limited to 'pyfakefs/tests/test_utils.py')
-rw-r--r--pyfakefs/tests/test_utils.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pyfakefs/tests/test_utils.py b/pyfakefs/tests/test_utils.py
index 27bd89f..b03ecdc 100644
--- a/pyfakefs/tests/test_utils.py
+++ b/pyfakefs/tests/test_utils.py
@@ -299,10 +299,12 @@ class RealFsTestMixin:
args = [to_string(arg) for arg in args]
return self.os.path.join(self.base_path, *args)
- def create_dir(self, dir_path):
+ def create_dir(self, dir_path, perm=0o777):
"""Create the directory at `dir_path`, including subdirectories.
`dir_path` shall be composed using `make_path()`.
"""
+ if not dir_path:
+ return
existing_path = dir_path
components = []
while existing_path and not self.os.path.exists(existing_path):
@@ -317,6 +319,7 @@ class RealFsTestMixin:
existing_path = self.os.path.join(existing_path, component)
self.os.mkdir(existing_path)
self.os.chmod(existing_path, 0o777)
+ self.os.chmod(dir_path, perm)
def create_file(self, file_path, contents=None, encoding=None, perm=0o666):
"""Create the given file at `file_path` with optional contents,