summaryrefslogtreecommitdiff
path: root/sphinx/testing/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/testing/util.py')
-rw-r--r--sphinx/testing/util.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/sphinx/testing/util.py b/sphinx/testing/util.py
index 450241f55..7d0cde143 100644
--- a/sphinx/testing/util.py
+++ b/sphinx/testing/util.py
@@ -4,15 +4,16 @@
Sphinx test suite utilities
- :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
+import functools
import os
import re
import sys
import warnings
from io import StringIO
-from typing import Any, Dict, Generator, IO, List, Pattern
+from typing import IO, Any, Dict, Generator, List, Pattern
from xml.etree import ElementTree
from docutils import nodes
@@ -20,13 +21,11 @@ from docutils.nodes import Node
from docutils.parsers.rst import directives, roles
from sphinx import application, locale
-from sphinx.builders.latex import LaTeXBuilder
from sphinx.deprecation import RemovedInSphinx40Warning
from sphinx.pycode import ModuleAnalyzer
from sphinx.testing.path import path
from sphinx.util.osutil import relpath
-
__all__ = [
'Struct',
'SphinxTestApp', 'SphinxTestAppWrapperForSkipBuilding',
@@ -108,7 +107,7 @@ class SphinxTestApp(application.Sphinx):
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) -> None:
+ tags: List[str] = None, docutilsconf: str = None, parallel: int = 0) -> None:
if docutilsconf is not None:
(srcdir / 'docutils.conf').write_text(docutilsconf)
@@ -133,14 +132,13 @@ class SphinxTestApp(application.Sphinx):
try:
super().__init__(srcdir, confdir, outdir, doctreedir,
buildername, confoverrides, status, warning,
- freshenv, warningiserror, tags)
+ freshenv, warningiserror, tags, parallel=parallel)
except Exception:
self.cleanup()
raise
def cleanup(self, doctrees: bool = False) -> None:
ModuleAnalyzer.cache.clear()
- LaTeXBuilder.usepackages = []
locale.translators.clear()
sys.path[:] = self._saved_path
sys.modules.pop('autodoc_fodder', None)
@@ -195,3 +193,13 @@ def find_files(root: str, suffix: bool = None) -> Generator[str, None, None]:
def strip_escseq(text: str) -> str:
return re.sub('\x1b.*?m', '', text)
+
+
+def simple_decorator(f):
+ """
+ A simple decorator that does nothing, for tests to use.
+ """
+ @functools.wraps(f)
+ def wrapper(*args, **kwargs):
+ return f(*args, **kwargs)
+ return wrapper