From 3a53e02f78f73712ed5fd2e2e1391401403199fe Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 15 Aug 2021 02:34:13 +0900 Subject: [PATCH] Close #9524: test: SphinxTestApp can take ``outdir`` as an argument --- CHANGES | 1 + sphinx/testing/util.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 1168fa8f60c..ead040bcd96 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ Features added template variable ``sphinx_version_tuple`` * #9445: py domain: ``:py:property:`` directive supports ``:classmethod:`` option to describe the class property +* #9524: test: SphinxTestApp can take ``outdir`` as an argument Bugs fixed ---------- diff --git a/sphinx/testing/util.py b/sphinx/testing/util.py index bfbb1071c5f..47933153bad 100644 --- a/sphinx/testing/util.py +++ b/sphinx/testing/util.py @@ -102,23 +102,26 @@ class SphinxTestApp(application.Sphinx): _status: StringIO = None _warning: StringIO = None - def __init__(self, buildername: str = 'html', srcdir: path = None, freshenv: bool = False, - confoverrides: Dict = None, status: IO = None, warning: IO = None, - tags: List[str] = None, docutilsconf: str = None, parallel: int = 0) -> None: + def __init__(self, buildername: str = 'html', srcdir: path = None, outdir: path = None, + freshenv: bool = False, confoverrides: Dict = None, status: IO = None, + warning: IO = None, tags: List[str] = None, docutilsconf: str = None, + parallel: int = 0) -> None: if docutilsconf is not None: (srcdir / 'docutils.conf').write_text(docutilsconf) - builddir = srcdir / '_build' confdir = srcdir - outdir = builddir.joinpath(buildername) - outdir.makedirs(exist_ok=True) - doctreedir = builddir.joinpath('doctrees') - doctreedir.makedirs(exist_ok=True) if confoverrides is None: confoverrides = {} warningiserror = False + if outdir is None: + outdir = srcdir / '_build' / buildername + + outdir.makedirs(exist_ok=True) + doctreedir = outdir / 'doctrees' + doctreedir.makedirs(exist_ok=True) + self._saved_path = sys.path[:] self._saved_directives = directives._directives.copy() # type: ignore self._saved_roles = roles._roles.copy() # type: ignore