@@ -2090,7 +2090,10 @@ def make_string_path(self, path: AnyPath) -> AnyStr: # type: ignore[type-var]
20902090 return path_str .replace (os_sep , fake_sep ) # type: ignore[return-value]
20912091
20922092 def create_dir (
2093- self , directory_path : AnyPath , perm_bits : int = helpers .PERM_DEF
2093+ self ,
2094+ directory_path : AnyPath ,
2095+ perm_bits : int = helpers .PERM_DEF ,
2096+ apply_umask : bool = True ,
20942097 ) -> FakeDirectory :
20952098 """Create `directory_path` and all the parent directories, and return
20962099 the created :py:class:`FakeDirectory<pyfakefs.fake_file.FakeDirectory>` object.
@@ -2100,6 +2103,8 @@ def create_dir(
21002103 Args:
21012104 directory_path: The full directory path to create.
21022105 perm_bits: The permission bits as set by ``chmod``.
2106+ apply_umask: If `True` (default), the current umask is applied
2107+ to `perm_bits`.
21032108
21042109 Returns:
21052110 The newly created
@@ -2138,7 +2143,9 @@ def create_dir(
21382143 # set the permission after creating the directories
21392144 # to allow directory creation inside a read-only directory
21402145 for new_dir in new_dirs :
2141- new_dir .st_mode = S_IFDIR | (perm_bits & ~ self .umask )
2146+ if apply_umask :
2147+ perm_bits &= ~ self .umask
2148+ new_dir .st_mode = S_IFDIR | perm_bits
21422149
21432150 return current_dir
21442151
@@ -2169,8 +2176,8 @@ def create_file(
21692176 the file is considered to be in "large file mode" and trying
21702177 to read from or write to the file will result in an exception.
21712178 create_missing_dirs: If `True`, auto create missing directories.
2172- apply_umask: `True` if the current umask must be applied
2173- on `st_mode`.
2179+ apply_umask: If `True` (default), the current umask is applied
2180+ to `st_mode`.
21742181 encoding: If `contents` is of type `str`, the encoding used
21752182 for serialization.
21762183 errors: The error mode used for encoding/decoding errors.
0 commit comments