tests.sphinx packageΒΆ
SubmodulesΒΆ
tests.sphinx.conftest moduleΒΆ
Fixtures and helpers for Sphinx tests.
Separated from the root tests/conftest.py so that the Sphinx dependency
(and its ecosystem: myst-parser, docutils, etc.) is only imported when running
the tests in this subdirectory. Downstream packagers can skip these tests with
--ignore=tests/sphinx without affecting the rest of the test suite.
- class tests.sphinx.conftest.FormatType(*values)[source]ΒΆ
Bases:
EnumSphinx document format types and their file extensions.
- RST = '.rst'ΒΆ
- MYST = '.md'ΒΆ
- class tests.sphinx.conftest.SphinxAppWrapper(app, format_type)[source]ΒΆ
Bases:
objectWrapper around Sphinx application with additional testing methods.
- classmethod create(format_type, tmp_path, return_srcdir=False, enable_exec_directives=True)[source]ΒΆ
Factory method to create a SphinxAppWrapper with given format.
enable_exec_directivesopts the test app into theclick:*andpython:*directive families. Defaults toTruefor every fixture-built app because the test suite primarily exercises those directives. Tests that verify the off-by-default production gate flip the flag back toFalseexplicitly.- Return type:
Generator[SphinxAppWrapper|tuple[SphinxAppWrapper,Path],None,None]
- tests.sphinx.conftest.sphinx_app(request, tmp_path)[source]ΒΆ
Create a Sphinx application for testing.
- tests.sphinx.conftest.sphinx_app_rst(tmp_path)[source]ΒΆ
Create a Sphinx application for testing RST format only.
The
click:*andpython:*directive families are enabled so tests can exercise them. Tests that explicitly verify the off-by- default opt-in gate construct their own app viaSphinxAppWrapper.create()withenable_exec_directives=False.
- tests.sphinx.conftest.sphinx_app_myst(tmp_path)[source]ΒΆ
Create a Sphinx application for testing MyST format only.
The
click:*andpython:*directive families are enabled β seesphinx_app_rst()for the rationale.
- tests.sphinx.conftest.sphinx_app_myst_with_include(tmp_path)[source]ΒΆ
Create a Sphinx application for testing MyST format with include files.
- class tests.sphinx.conftest.DirectiveTestCase(name, format_type=None, source_block=None, run_block=None, document=None, html_matches=None)[source]ΒΆ
Bases:
objectTest case data for directive tests.
- format_type: FormatType | None = NoneΒΆ
- tests.sphinx.conftest.python_block(*lines)[source]ΒΆ
Build expected Python highlight block.
- Return type:
tests.sphinx.test_sphinx moduleΒΆ
Fixtures and utilities for Sphinx testing.
tests.sphinx.test_sphinx_alerts moduleΒΆ
Tests for GitHub alert syntax conversion in Sphinx with MyST parser.
- tests.sphinx.test_sphinx_alerts.test_all_alert_types(alert_type)[source]ΒΆ
Test all supported alert types are converted correctly.
- tests.sphinx.test_sphinx_alerts.test_alert_conversion(text, expected)[source]ΒΆ
Test GitHub alerts are converted to MyST admonitions.
When expected is None, no conversion should occur.
- tests.sphinx.test_sphinx_alerts.test_sphinx_integration(sphinx_app, test_case)[source]ΒΆ
Integration-critical tests that verify Sphinx rendering behavior.
tests.sphinx.test_sphinx_click moduleΒΆ
Tests for Sphinx directives click:source and click:run in rST and MyST formats.
- tests.sphinx.test_sphinx_click.test_directive_functionality(sphinx_app, test_case)[source]ΒΆ
Test standard directive functionalities in both rST and MyST.
- tests.sphinx.test_sphinx_click.test_directive_option_format(sphinx_app_rst)[source]ΒΆ
rST will fail to render if an
:option:is not followed by an empty line.
- tests.sphinx.test_sphinx_click.test_directive_option_language_override(sphinx_app)[source]ΒΆ
Test that language override works for click:run directive.
- tests.sphinx.test_sphinx_click.test_sphinx_directive_state_persistence(sphinx_app)[source]ΒΆ
Test that state persists between declare and run directives in real Sphinx.