Skip to content
Open
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
2 changes: 1 addition & 1 deletion cuda_pathfinder/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def pytest_configure(config):
def pytest_terminal_summary(terminalreporter, exitstatus, config):
if not config.getoption("verbose"):
return
if hasattr(config.option, "iterations"): # pytest-freethreaded runs all tests at least twice
if getattr(config.option, "iterations", 1) > 1: # pytest-freethreaded runs all tests at least twice
return
if getattr(config.option, "count", 1) > 1: # pytest-repeat
return
Expand Down
74 changes: 74 additions & 0 deletions cuda_pathfinder/tests/test_conftest_info_summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""The INFO summary is the only output of the info_summary_append fixture.

Several suites (test_load_nvidia_dynamic_lib, test_driver_lib_loading,
test_find_*) report what they discovered exclusively through it, so the
conditions that suppress it are worth pinning down.
"""

from __future__ import annotations

import types

import pytest
from conftest import pytest_terminal_summary


class FakeTerminalReporter:
def __init__(self) -> None:
self.lines: list[str] = []

def write_sep(self, sep: str, title: str) -> None:
self.lines.append(f"{sep} {title}")

def line(self, message: str) -> None:
self.lines.append(message)


def make_config(**option_attrs: object) -> types.SimpleNamespace:
option = types.SimpleNamespace(verbose=1, **option_attrs)
return types.SimpleNamespace(
option=option,
custom_info=["some_test: hdr_dir='/somewhere'"],
getoption=lambda name: getattr(option, name),
)


@pytest.mark.agent_authored(model="claude-opus-5")
@pytest.mark.parametrize(
"option_attrs",
[
{}, # neither plugin installed
{"iterations": 1}, # pytest-freethreaded installed, single iteration
{"count": 1}, # pytest-repeat installed, single run
{"iterations": 1, "count": 1},
],
ids=["no-plugins", "freethreaded-single", "repeat-single", "both-single"],
)
def test_info_summary_is_emitted_for_a_single_pass(option_attrs):
reporter = FakeTerminalReporter()
pytest_terminal_summary(reporter, 0, make_config(**option_attrs))
assert reporter.lines == ["= INFO summary", "INFO some_test: hdr_dir='/somewhere'"]


@pytest.mark.agent_authored(model="claude-opus-5")
@pytest.mark.parametrize(
"option_attrs",
[{"iterations": 2}, {"count": 2}],
ids=["freethreaded-repeats", "repeat-repeats"],
)
def test_info_summary_is_suppressed_when_tests_repeat(option_attrs):
reporter = FakeTerminalReporter()
pytest_terminal_summary(reporter, 0, make_config(**option_attrs))
assert reporter.lines == []


@pytest.mark.agent_authored(model="claude-opus-5")
def test_info_summary_is_suppressed_without_verbose():
reporter = FakeTerminalReporter()
config = make_config()
config.option.verbose = 0
pytest_terminal_summary(reporter, 0, config)
assert reporter.lines == []
Loading