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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_pytest-0.3.0.tar.gz.
File metadata
- Download URL: sphinx_pytest-0.3.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
141a3d6b6cd8616ded72a949a2e7ba8b95e811e58f1118fa1ddeb8c61c3b6364
|
|
| MD5 |
8e145b9c4473396ee37f62b6052c47c0
|
|
| BLAKE2b-256 |
4eb0b6123b64e27b37fada7291df8a482cb2dc6de0dc79bd75c4f97d65f6d96e
|
File details
Details for the file sphinx_pytest-0.3.0-py3-none-any.whl.
File metadata
- Download URL: sphinx_pytest-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
548bbf5be054efdf73c4a32fd685c86817afcccc51c7e2bd112f9905b34fd739
|
|
| MD5 |
7a1533a1a7aec82e6bcbced5711a2766
|
|
| BLAKE2b-256 |
15c5cee80eb395176413cbd91aa56ca1c9f8827c2d5fd97a424ef95087656437
|