1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Set test env vars before the pygitweb package is imported (see pygitweb/conftest.py)."""
from __future__ import annotations
import os
from pathlib import Path
import pytest
_test_auth_config = Path(os.environ.get("TEMP", "/tmp")) / "pygitweb-test-auth.json"
_test_settings_config = Path(os.environ.get("TEMP", "/tmp")) / "pygitweb-test-settings.json"
os.environ.setdefault("PYGITWEB_AUTH", "0")
os.environ.setdefault("PYGITWEB_AUTH_CONFIG", str(_test_auth_config))
os.environ.setdefault("PYGITWEB_SETTINGS_CONFIG", str(_test_settings_config))
def pytest_addoption(parser: pytest.Parser) -> None:
parser.addoption(
"--js-tests",
action="store_true",
default=False,
help="Run JavaScript unit tests (requires the stpyv8 or pythonmonkey group)",
)
def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]) -> None:
if config.getoption("--js-tests"):
return
skip = pytest.mark.skip(reason="JS tests are off by default; pass --js-tests to run them")
for item in items:
if "static_tests" in item.path.parts:
item.add_marker(skip)