Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions changelog/9422.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix bug where disabling the terminal plugin via ``-p no:terminal`` would cause crashes related to missing the ``verbose`` option.

-- by :user:`GTowers1`
2 changes: 1 addition & 1 deletion doc/en/example/simple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ display more information if applicable:


def pytest_report_header(config):
if config.getoption("verbose") > 0:
if config.getoption("verbose", 0) > 0:
return ["info1: did you know that ...", "did you?"]

which will add info only when run with "--v":
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def get_last_failed_paths(self) -> set[Path]:
return {x for x in result if x.exists()}

def pytest_report_collectionfinish(self) -> str | None:
if self.active and self.config.getoption("verbose") >= 0:
if self.active and self.config.getoption("verbose", 0) >= 0:
return f"run-last-failure: {self._report_status}"
return None

Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def pytest_runtestloop(self, session: Session) -> Generator[None, object, object
if session.config.option.collectonly:
return (yield)

if self._log_cli_enabled() and self._config.getoption("verbose") < 1:
if self._log_cli_enabled() and self._config.getoption("verbose", 0) < 1:
# The verbose flag is needed to avoid messy test progress output.
self._config.option.verbose = 1

Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def importtestmodule(
) from e
except ImportError as e:
exc_info = ExceptionInfo.from_current()
if config.getoption("verbose") < 2:
if config.getoption("verbose", 0) < 2:
exc_info.traceback = exc_info.traceback.filter(filter_traceback)
exc_repr = (
exc_info.getrepr(style="short")
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/stepwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
self.lastfailed = None

def pytest_report_collectionfinish(self) -> str | None:
if self.config.getoption("verbose") >= 0 and self.report_status:
if self.config.getoption("verbose", 0) >= 0 and self.report_status:
return f"stepwise: {self.report_status}"
return None

Expand Down
2 changes: 1 addition & 1 deletion testing/python/approx.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def report_failure(self, out, test, example, got):

@contextmanager
def temporary_verbosity(config, verbosity=0):
original_verbosity = config.getoption("verbose")
original_verbosity = config.getoption("verbose", 0)
config.option.verbose = verbosity
try:
yield
Expand Down
2 changes: 1 addition & 1 deletion testing/test_assertrewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def f() -> None:
msg = getmsg(f)
assert msg is not None
line = msg.splitlines()[0]
if request.config.getoption("verbose") > 1:
if request.config.getoption("verbose", 0) > 1:
assert line == (
"assert '12345678901234567890123456789012345678901234567890A' "
"== '12345678901234567890123456789012345678901234567890B'"
Expand Down