File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ Steps to develop the theme
1141142. Install theme dependencies
1151153. Run development server
1161164. Build production assets
117+ 5. Install the testing infrastructure
117118
118119.. Attention ::
119120
@@ -189,6 +190,28 @@ run:
189190 yarn build:production
190191
191192
193+ Install the test infrastructure
194+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
195+
196+ This theme uses ``pytest `` for its testing, with a lightweight fixture defined
197+ in the ``test_build.py `` script that makes it easy to run a Sphinx build using
198+ this theme and inspect the results.
199+
200+ In addition, we use `pytest-regressions <https://pytest-regressions.readthedocs.io/en/latest/ >`_
201+ to ensure that the HTML generated by the theme is what we'd expect. This module
202+ provides a ``file_regression `` fixture that will check the contents of an object
203+ against a reference file on disk. If the structure of the two differs, then the
204+ test will fail. If we *expect * the structure to differ, then delete the file on
205+ disk and run the test. A new file will be created, and subsequent tests will pass.
206+
207+ Install the testing dependencies with:
208+
209+ .. code-block :: bash
210+
211+ pip install pytest pytest-regressions
212+
213+ Then run the tests by calling ``pytest `` from the repository root.
214+
192215Changing fonts
193216--------------
194217
Original file line number Diff line number Diff line change 1717html_sourcelink_suffix = ""
1818
1919# Base options, we can add other key/vals later
20- html_theme_options = {
21- }
20+ html_theme_options = {}
Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ def test_build_book(file_regression, sphinx_build):
6363
6464 # Sidebar subpage
6565 sidebar = subpage_html .select (".bd-sidebar" )[0 ]
66- file_regression .check (sidebar .prettify (), basename = "sidebar_subpage" , extension = ".html" )
66+ file_regression .check (
67+ sidebar .prettify (), basename = "sidebar_subpage" , extension = ".html"
68+ )
6769
6870 sphinx_build .clean ()
You can’t perform that action at this time.
0 commit comments