diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-11-16 05:01:54 -0800 |
---|---|---|
committer | Jon Dufresne <jon.dufresne@gmail.com> | 2018-11-20 18:37:05 -0800 |
commit | 77849f0ef6d80fc636f457c2d8925c4932c406c9 (patch) | |
tree | 270f19661ab4fdcf3a53f122688532018262744d /sphinx/testing/util.py | |
parent | 2cbc921946c20e072965f746090003fe41f5ddf1 (diff) | |
download | sphinx-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/util.py')
-rw-r--r-- | sphinx/testing/util.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/sphinx/testing/util.py b/sphinx/testing/util.py index 4b508e1e6..1f575569a 100644 --- a/sphinx/testing/util.py +++ b/sphinx/testing/util.py @@ -116,11 +116,9 @@ class SphinxTestApp(application.Sphinx): builddir = srcdir / '_build' confdir = srcdir outdir = builddir.joinpath(buildername) - if not outdir.isdir(): - outdir.makedirs() + outdir.makedirs(exist_ok=True) doctreedir = builddir.joinpath('doctrees') - if not doctreedir.isdir(): - doctreedir.makedirs() + doctreedir.makedirs(exist_ok=True) if confoverrides is None: confoverrides = {} warningiserror = False |