Helpful pytest fixtures for sphinx extensions.
Project Links
Meta
Author: Chris Sewell
Requires Python: >=3.7
Classifiers
License
- OSI Approved :: MIT License
Programming Language
- Python :: 3
- Python :: Implementation :: CPython
Topic
- Software Development :: Libraries :: Python Modules
Framework
- Pytest
sphinx-pytest
Helpful pytest fixtures for sphinx extensions.
Sphinx is annoying, because the modularity is not great, meaning that there is no real way just to convert single documents in isolation, etc.
This extension mainly provides some pytest fixtures to "simulate" converting some source text to docutils AST at different stages; before transforms, after transforms, etc.
Installation
pip install sphinx-pytest
Examples
from sphinx_pytest.plugin import CreateDoctree
def test_no_transforms(sphinx_doctree_no_tr: CreateDoctree):
"""Return the doctree, before any transforms have been applied."""
sphinx_doctree_no_tr.set_conf({"language": "en"})
result = sphinx_doctree_no_transforms(".. _target:\n\nheader\n------\n")
assert (
result.pformat()
== """\
<document source="<src>/index.rst">
<target ids="target" names="target">
<section ids="header" names="header">
<title>
header
""".rstrip()
)
def test_with_transforms(sphinx_doctree: CreateDoctree):
"""Return the doctree, after transforms (but not post-transforms)."""
result = sphinx_doctree(".. _target:\n\nheader\n------\n")
assert (
result.pformat()
== """\
<document source="<src>/index.rst">
<target refid="target">
<section ids="header target" names="header target">
<title>
header
""".rstrip()
)
Sep 20, 2023
0.2.0
Jun 05, 2023
0.1.1
Sep 11, 2022
0.0.5
Jun 24, 2022
0.0.4
May 10, 2022
0.0.3
May 09, 2022
0.0.2
May 09, 2022
0.0.1