Helpful pytest fixtures for sphinx extensions.
Project description
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
def test_no_transforms(sphinx_doctree_no_tr):
"""Return the doctree, before any transforms have been applied."""
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):
"""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()
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sphinx_pytest-0.0.1.tar.gz
(5.4 kB
view hashes)
Built Distribution
Close
Hashes for sphinx_pytest-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fbfdb554a3b667052131a914e16d3aae25fa8c6e079aed433371b2e6cb1aaee |
|
MD5 | e6feea82d01201e9fe74bf5990071ade |
|
BLAKE2b-256 | 7db1e2d7f94764e3a2ab8d1db5bed8d58681947b5c83420fecd891d52e4c9c75 |