From 290d8471bba35980f3e228f9c171afc40f2550fa Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 31 Jan 2019 07:12:55 -0800 Subject: Fixed #30147 -- Simplified directory creation with os.makedirs(..., exist_ok=True). --- tests/file_storage/tests.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/file_storage') 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: -- cgit v1.2.1