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
5 changes: 4 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,12 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None:
exitstatus = pytest.ExitCode.OK
session.exitstatus = pytest.ExitCode.OK

if session.config.option.collectonly:
return

context.scenario.pytest_sessionfinish(session, exitstatus)

if session.config.option.collectonly or session.config.option.replay:
if session.config.option.replay:
return

# xdist: pytest_sessionfinish function runs at the end of all tests. If you check for the worker input attribute,
Expand Down
2 changes: 2 additions & 0 deletions utils/_context/_scenarios/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def __init__(
group.scenarios.append(self)

self.warmups: list[Callable] = []
self.collect_only: bool = False

def _create_log_subfolder(self, subfolder: str, *, remove_if_exists: bool = False):
if self.replay:
Expand All @@ -148,6 +149,7 @@ def __call__(self, test_object): # noqa: ANN001 (tes_object can be a class or a

def pytest_configure(self, config: pytest.Config):
self.replay = config.option.replay
self.collect_only = config.option.collectonly

# https://github.com/pytest-dev/pytest-xdist/issues/271#issuecomment-826396320
# we are in the main worker, not in a xdist sub-worker
Expand Down
3 changes: 3 additions & 0 deletions utils/_context/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class _Context:
scenario: Scenario # will be set by pytest_configure

def _get_scenario_property(self, name: str, default: Any) -> Any: # noqa:ANN401
if self.scenario.collect_only:
return default

if hasattr(self.scenario, name):
return getattr(self.scenario, name)

Expand Down
4 changes: 2 additions & 2 deletions utils/proxy/scrubber.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def write(data: str):
for secret in secrets:
data = data.replace(secret, "--redacted--")

original_write(data)
return original_write(data)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change belongs to this PR ?

Copy link
Copy Markdown
Contributor Author

@florentinl florentinl Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the vscode extension injects a pytest plugin that inherits the wrapped write and needs its return value. Otherwise the test discovery crashes.


f.write = write

Expand All @@ -45,7 +45,7 @@ def write(data: bytes):
for secret in secrets:
data = data.replace(secret.encode(), b"--redacted--")

original_write(data)
return original_write(data)

f.write = write

Expand Down
Loading