Skip to content
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
13 changes: 13 additions & 0 deletions docs/examples/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,25 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)

def runtest(self):
import os
import pathlib

repo_root = str(pathlib.Path(__file__).parent.parent.parent.resolve())
env = os.environ.copy()
existing_pythonpath = env.get("PYTHONPATH", "")
env["PYTHONPATH"] = (
f"{existing_pythonpath}{os.pathsep}{repo_root}"
if existing_pythonpath
else repo_root
)

process = subprocess.Popen(
[sys.executable, self.path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=1, # Enable line-buffering
env=env,
)

# Capture stdout output and output it so it behaves like a regular test with -s.
Expand Down
5 changes: 5 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ def _run_heavy_modules_isolated(session, heavy_modules: list[str]) -> int:
if markexpr:
cmd.extend(["-m", markexpr])

import pathlib

repo_root = str(pathlib.Path(__file__).parent.parent.resolve())
env["PYTHONPATH"] = f"{repo_root}{os.pathsep}{env.get('PYTHONPATH', '')}"

# Stream output in real-time while capturing for parsing
process = subprocess.Popen(
cmd,
Expand Down