summaryrefslogtreecommitdiff
path: root/sphinx/testing/path.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2018-11-16 05:01:54 -0800
committerJon Dufresne <jon.dufresne@gmail.com>2018-11-20 18:37:05 -0800
commit77849f0ef6d80fc636f457c2d8925c4932c406c9 (patch)
tree270f19661ab4fdcf3a53f122688532018262744d /sphinx/testing/path.py
parent2cbc921946c20e072965f746090003fe41f5ddf1 (diff)
downloadsphinx-git-77849f0ef6d80fc636f457c2d8925c4932c406c9.tar.gz
Simplify ensuredir() with Python3 stdlib features
- Simplify ensuredir() to equivalent os.makedir(name, exist_ok=True) - Do not check if a directory exists before calling ensuredir() (ensuredir() already handles it) - Add exist_ok argument to path.makedirs() to follow same pattern - Drop unnecessary .exists() check immediately before .isdir() - Add tests for ensuredir
Diffstat (limited to 'sphinx/testing/path.py')
-rw-r--r--sphinx/testing/path.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/sphinx/testing/path.py b/sphinx/testing/path.py
index 78c3cb7bc..143bfd994 100644
--- a/sphinx/testing/path.py
+++ b/sphinx/testing/path.py
@@ -202,12 +202,12 @@ class path(text_type):
"""
return os.path.lexists(self)
- def makedirs(self, mode=0o777):
- # type: (int) -> None
+ def makedirs(self, mode=0o777, exist_ok=False):
+ # type: (int, bool) -> None
"""
Recursively create directories.
"""
- os.makedirs(self, mode)
+ os.makedirs(self, mode, exist_ok=exist_ok) # type: ignore
def joinpath(self, *args):
# type: (Any) -> path