Skip to content

Commit 9e3a0c4

Browse files
committed
Add env variable to control test-them build location.
I needed this to debug some things, so why not send it as a PR. See #1798, maybe this should be folded in #1759 ?
1 parent f30dec3 commit 9e3a0c4

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

tests/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,18 @@ This directory contains the Python tests for the theme. These tests are built wi
2626
The ["Kitchen Sink" examples](https://pydata-sphinx-theme.readthedocs.io/en/stable/examples/kitchen-sink/index.html)
2727
are taken from [sphinx-themes.org](https://sphinx-themes.org/) and showcase
2828
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 `nox -s test` 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+
```
40+
$ PST_TEST_HTML_DIR=./debug-test-theme/ nox -s test
41+
```
42+
43+
Will save all the generated html in the folders `./debug-test-theme/<test-name>/<site-name>`

tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Configuration of the pytest session."""
22

33
import re
4+
from os import environ
45
from pathlib import Path
56
from shutil import copytree
67
from typing import Callable
@@ -65,11 +66,14 @@ def html_tree(self, *path) -> str:
6566

6667

6768
@pytest.fixture()
68-
def sphinx_build_factory(make_app: Callable, tmp_path: Path) -> Callable:
69+
def sphinx_build_factory(make_app: Callable, tmp_path: Path, request) -> Callable:
6970
"""Return a factory builder pointing to the tmp directory."""
7071

71-
def _func(src_folder: Path, **kwargs) -> SphinxBuild:
72+
def _func(src_folder: str, **kwargs) -> SphinxBuild:
7273
"""Create the Sphinxbuild from the source folder."""
74+
no_temp = environ.get("PST_TEST_HTML_DIR", None)
75+
if no_temp is not None:
76+
tmp_path = Path(no_temp) / request.node.name / str(src_folder)
7377
srcdir = tmp_path / src_folder
7478
if sphinx.version_info < (7, 2):
7579
from sphinx.testing.path import path as sphinx_path

0 commit comments

Comments
 (0)