Sphinxtesters - utilities for testing Sphinx extensions
Quickstart
If you have a directory containing a sphinx project, test that it builds with something like:
class TestMyProject(SourcesBuilder):
page_source_template = 'path/to/sphinx_dir'
def test_basic_build(self):
# Get doctree for page "a_page.rst"
doctree = self.get_doctree('a_page')
# Assert stuff about doctree version of page
html = self.get_built_file('a_page.html')
# Assert stuff about html version of page
You can try adding other page content by using the rst_sources dictionary:
class TestChangedProject(SourcesBuilder):
page_source_template = 'path/to/sphinx_dir'
rst_sources = {'a_page': """Replacement text for page""",
'b_page': """An entirely new page"""}
def test_basic_build(self):
a_doctree = self.get_doctree('a_page')
b_doctree = self.get_doctree('b_page')
# Your tests for the new page content here
Set the text of the conf.py file with the conf_source attribute:
class TestConfeddProject(SourcesBuilder):
page_source_template = 'path/to/sphinx_dir'
rst_sources = {'a_page': """Replacement text for page""",
'b_page': """An entirely new page"""}
conf_source = """ # This overwrites existing conf.py """
def test_basic_build(self):
a_doctree = self.get_doctree('a_page')
b_doctree = self.get_doctree('b_page')
# Your tests for the new page content here
You don’t need to set page_source_template; if you don’t, you start with a fresh project, where the only pages are the ones you specify in rst_sources.
class TestFreshProject(SourcesBuilder):
rst_sources = {'a_page': """A new page""",
'b_page': """Another new page"""}
conf_source = """ # Stuff for the conf.py file """
def test_basic_build(self):
a_doctree = self.get_doctree('a_page')
b_doctree = self.get_doctree('b_page')
# Your tests for the new page content here
See the tests for examples of using Sphinxtesters for testing builds of Sphinx projects.
Installation
pip install sphinxtesters
Code
See https://github.com/matthew-brett/sphinxtesters
Released under the BSD two-clause license - see the file LICENSE in the source distribution.
travis-ci kindly tests the code automatically under Python versions 2.7, and 3.3 through 3.6.
The latest released version is at https://pypi.python.org/pypi/sphinxtesters
Tests
Install sphinxtesters
Install the pytest testing framework:
pip install pytest
Run the tests with:
pytest sphinxtesters
Support
Please put up issues on the sphinxtesters issue tracker.
Metadata
Release files for sphinxtesters 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sphinxtesters-0.2.4.tar.gz | 11.4 kB | Without provenance | Details for sphinxtesters-0.2.4.tar.gz |
Release files / sphinxtesters-0.2.4.tar.gz
| Download URL | sphinxtesters-0.2.4.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
09c456e1cd61ec99b64851e2990d2152fdf05bb53d87f3b294f22d73f939d6ca
|
|
BLAKE2b-256 checksum How to use checksums |
aa0893af63fc5c6fd4c66b84a92c0048c5d2134fd168c6d763b01a476a3496f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for sphinxtesters 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.