A subclass of :class:`~sphinx.application.Sphinx` for tests. The constructor uses some better default values for the initialization parameters and supports arbitrary keywords stored in the :attr:`extras` read-only mapping. It is recommended to use:: @pytest.mark.sphinx('ht
| 83 | |
| 84 | |
| 85 | class SphinxTestApp(sphinx.application.Sphinx): |
| 86 | """A subclass of :class:`~sphinx.application.Sphinx` for tests. |
| 87 | |
| 88 | The constructor uses some better default values for the initialization |
| 89 | parameters and supports arbitrary keywords stored in the :attr:`extras` |
| 90 | read-only mapping. |
| 91 | |
| 92 | It is recommended to use:: |
| 93 | |
| 94 | @pytest.mark.sphinx('html', testroot='root') |
| 95 | def test(app): |
| 96 | app = ... |
| 97 | |
| 98 | instead of:: |
| 99 | |
| 100 | def test(): |
| 101 | app = SphinxTestApp('html', srcdir=srcdir) |
| 102 | |
| 103 | In the former case, the 'app' fixture takes care of setting the source |
| 104 | directory, whereas in the latter, the user must provide it themselves. |
| 105 | """ |
| 106 | |
| 107 | # see https://github.com/sphinx-doc/sphinx/pull/12089 for the |
| 108 | # discussion on how the signature of this class should be used |
| 109 | |
| 110 | def __init__( |
| 111 | self, |
| 112 | /, # to allow 'self' as an extras |
| 113 | buildername: str = 'html', |
| 114 | srcdir: Path | None = None, |
| 115 | builddir: Path | None = None, # extra constructor argument |
| 116 | freshenv: bool = False, # argument is not in the same order as in the superclass |
| 117 | confoverrides: dict[str, Any] | None = None, |
| 118 | status: StringIO | None = None, |
| 119 | warning: StringIO | None = None, |
| 120 | tags: Sequence[str] = (), |
| 121 | docutils_conf: str | None = None, # extra constructor argument |
| 122 | parallel: int = 0, |
| 123 | # additional arguments at the end to keep the signature |
| 124 | verbosity: int = 0, # argument is not in the same order as in the superclass |
| 125 | warningiserror: bool = False, # argument is not in the same order as in the superclass |
| 126 | pdb: bool = False, |
| 127 | exception_on_warning: bool = False, |
| 128 | # unknown keyword arguments |
| 129 | **extras: Any, |
| 130 | ) -> None: |
| 131 | self._builder_name = buildername |
| 132 | |
| 133 | assert srcdir is not None |
| 134 | |
| 135 | if verbosity == -1: |
| 136 | quiet = True |
| 137 | verbosity = 0 |
| 138 | else: |
| 139 | quiet = False |
| 140 | |
| 141 | if status is None: |
| 142 | # ensure that :attr:`status` is a StringIO and not sys.stdout |
no outgoing calls
searching dependent graphs…