Skip to content

Add env variable to control test-them build location. #1800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,18 @@ This directory contains the Python tests for the theme. These tests are built wi
The ["Kitchen Sink" examples](https://pydata-sphinx-theme.readthedocs.io/en/stable/examples/kitchen-sink/index.html)
are taken from [sphinx-themes.org](https://sphinx-themes.org/) and showcase
components of the PyData Sphinx Theme, such as admonitions, lists, and headings.

## visually debugging the test pages

It can be useful to build and inspect the test pages in the browser.

By default `nox -s test` will build the html in a temporary directory.
You can change this by using the `PST_TEST_HTML_DIR` environment variable.

For example:

```
$ PST_TEST_HTML_DIR=./debug-test-theme/ nox -s test
```

Will save all the generated html in the folders `./debug-test-theme/<test-name>/<site-name>`
9 changes: 7 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Configuration of the pytest session."""

import re
from os import environ
from pathlib import Path
from shutil import copytree
from typing import Callable
Expand Down Expand Up @@ -65,11 +66,15 @@ def html_tree(self, *path) -> str:


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

def _func(src_folder: Path, **kwargs) -> SphinxBuild:
def _func(src_folder: str, **kwargs) -> SphinxBuild:
"""Create the Sphinxbuild from the source folder."""
no_temp = environ.get("PST_TEST_HTML_DIR")
nonlocal tmp_path
if no_temp is not None:
tmp_path = Path(no_temp) / request.node.name / str(src_folder)
srcdir = tmp_path / src_folder
if sphinx.version_info < (7, 2):
from sphinx.testing.path import path as sphinx_path
Expand Down
Loading