Skip to content

Commit

Permalink
blackifying tests
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Jul 19, 2020
1 parent 938be79 commit 32b13bf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
23 changes: 23 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Steps to develop the theme
2. Install theme dependencies
3. Run development server
4. Build production assets
5. Install the testing infrastructure

.. Attention::

Expand Down Expand Up @@ -189,6 +190,28 @@ run:
yarn build:production
Install the test infrastructure
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This theme uses ``pytest`` for its testing, with a lightweight fixture defined
in the ``test_build.py`` script that makes it easy to run a Sphinx build using
this theme and inspect the results.

In addition, we use `pytest-regressions <https://pytest-regressions.readthedocs.io/en/latest/>`_
to ensure that the HTML generated by the theme is what we'd expect. This module
provides a ``file_regression`` fixture that will check the contents of an object
against a reference file on disk. If the structure of the two differs, then the
test will fail. If we *expect* the structure to differ, then delete the file on
disk and run the test. A new file will be created, and subsequent tests will pass.

Install the testing dependencies with:

.. code-block:: bash
pip install pytest pytest-regressions
Then run the tests by calling ``pytest`` from the repository root.

Changing fonts
--------------

Expand Down
3 changes: 1 addition & 2 deletions tests/sites/base/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
html_sourcelink_suffix = ""

# Base options, we can add other key/vals later
html_theme_options = {
}
html_theme_options = {}
4 changes: 3 additions & 1 deletion tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def test_build_book(file_regression, sphinx_build):

# Sidebar subpage
sidebar = subpage_html.select(".bd-sidebar")[0]
file_regression.check(sidebar.prettify(), basename="sidebar_subpage", extension=".html")
file_regression.check(
sidebar.prettify(), basename="sidebar_subpage", extension=".html"
)

sphinx_build.clean()

0 comments on commit 32b13bf

Please sign in to comment.