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
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()
)
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.2.0.tar.gz
(7.1 kB
view details)
Built Distribution
File details
Details for the file sphinx_pytest-0.2.0.tar.gz
.
File metadata
- Download URL: sphinx_pytest-0.2.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c26f5c39ed8600eb4f554d07034f114952c101a011f7fcfeed72c28ffe12670 |
|
MD5 | 7cd66038ae92d0e5d523c38aca66782b |
|
BLAKE2b-256 | 3e9dc83b6507b88f134a51fc97a952f627c327cf78189faaf857a93ef01ea1f8 |
File details
Details for the file sphinx_pytest-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: sphinx_pytest-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c64d68bf29af7a0432360d9e0624417e1c1378bbff53bd3229936b47ed8446fd |
|
MD5 | 98b35d7f8128eccb81f22845d45209b5 |
|
BLAKE2b-256 | b1bb4e8bf4554dc02d2f83cbd4ffb75e29673d746783d251280e9a54d0fa59dc |