summaryrefslogtreecommitdiff
path: root/tests/file_storage
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-01-31 07:12:55 -0800
committerTim Graham <timograham@gmail.com>2019-01-31 12:53:36 -0500
commit290d8471bba35980f3e228f9c171afc40f2550fa (patch)
treea05caec39f83a6d83594d5240fe39c3587316e35 /tests/file_storage
parentba7a420012799b26ec9e969d0276d2ccee93c1f5 (diff)
downloaddjango-290d8471bba35980f3e228f9c171afc40f2550fa.tar.gz
Fixed #30147 -- Simplified directory creation with os.makedirs(..., exist_ok=True).
Diffstat (limited to 'tests/file_storage')
-rw-r--r--tests/file_storage/tests.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index 991f1ff8cd..434869554c 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -410,12 +410,13 @@ class FileStorageTests(SimpleTestCase):
# Monkey-patch os.makedirs, to simulate a normal call, a raced call,
# and an error.
- def fake_makedirs(path):
+ def fake_makedirs(path, mode=0o777, exist_ok=False):
if path == os.path.join(self.temp_dir, 'normal'):
- real_makedirs(path)
+ real_makedirs(path, mode, exist_ok)
elif path == os.path.join(self.temp_dir, 'raced'):
- real_makedirs(path)
- raise FileExistsError()
+ real_makedirs(path, mode, exist_ok)
+ if not exist_ok:
+ raise FileExistsError()
elif path == os.path.join(self.temp_dir, 'error'):
raise PermissionError()
else: