Debian Codegraph @

tests/README.md

raw
1 # PyData Sphinx tests
2
3 This directory contains the Python tests for the theme. These tests are built with [pytest](https://docs.pytest.org/en/stable/) and are called through `tox`.
4
5 - `test_build.py` checks that the static HTML output of the build process conforms
6 to various expectations. It builds static HTML pages based on configurations in
7 the `sites/` directory. The tests run various assertions on the static HTML
8 output, including snapshot comparisons with previously compiled outputs that are
9 stored in `test_build/`. In other words, it uses
10 [`pytest-regressions`](https://pytest-regressions.readthedocs.io/) to compare
11 the output created during the test run with a previously known and verified output
12 (stored under `test_build`) to make sure nothing has changed.
13
14 - `test_a11y.py` checks PyData Sphinx Theme components for accessibility issues.
15 It's important to note that [only a fraction of accessibility issues can be
16 caught with automated
17 testing](https://accessibility.blog.gov.uk/2017/02/24/what-we-found-when-we-tested-tools-on-the-worlds-least-accessible-webpage/).
18 In contrast to the build test suite, the accessibility suite checks components as
19 they appear in the browser, meaning with any CSS and JavaScript applied. It does
20 this by building the PyData Sphinx Theme docs, launching a local server to the
21 docs, and then checking the "Kitchen Sink" example pages with
22 [Playwright](https://playwright.dev), a program for developers that allows
23 loading and manipulating pages with various browsers, such as Chrome (chromium),
24 Firefox (gecko), Safari (WebKit).
25
26 The ["Kitchen Sink" examples](https://pydata-sphinx-theme.readthedocs.io/en/stable/examples/kitchen-sink/index.html)
27 are taken from [sphinx-themes.org](https://sphinx-themes.org/) and showcase
28 components of the PyData Sphinx Theme, such as admonitions, lists, and headings.
29
30 ## Visually debugging the test pages
31
32 It can be useful to build and inspect the test pages in the browser.
33
34 By default, `tox run -m tests` (or any other `tox` command that runs our tests) will build the HTML in a temporary directory.
35 You can change this by using the `PST_TEST_HTML_DIR` environment variable.
36
37 For example:
38
39 ```bash
40 $ PST_TEST_HTML_DIR=./debug-test-theme/ tox run -m tests
41 ```
42
43 Will save all the generated HTML in the folders `./debug-test-theme/<test-name>/<site-name>`