Skip to content

Raise UsageError for invalid tmp_path_retention_count - #15464

Open
RonnyPfannschmidt wants to merge 1 commit into
mainfrom
claude/project-thread-cukdhn-retention
Open

RonnyPfannschmidt wants to merge 1 commit into
mainfrom
claude/project-thread-cukdhn-retention

Conversation

@RonnyPfannschmidt

Copy link
Copy Markdown
Member

Requested by Ronny · project thread

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

Follow-up to #15296. A non-numeric tmp_path_retention_count (e.g. "banana" in TOML) and a negative count used to crash with a raw ValueError traceback. They now raise a UsageError that names the option, like get_verbosity does. There are new tests for both cases.


Generated by Claude Code

A non-numeric string (e.g. "banana" in TOML) hit int() and a negative
count hit an explicit ValueError, both reported as internal error
tracebacks. Raise UsageError naming the option instead, as
Config.get_verbosity does for the verbosity options.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@SemTiOne SemTiOne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

Comment thread src/_pytest/tmpdir.py
Comment on lines 104 to 105
# A str only gets here from TOML: in ini mode the int member of
# the option type already converted it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: a string can also reach this branch from INI when the int member of the int | str union rejects it and the union falls back to str. Perhaps we could adjust the comment to reflect both cases?

Suggested change
# A str only gets here from TOML: in ini mode the int member of
# the option type already converted it.
# Integer strings in TOML are accepted for backward compatibility.
# Invalid strings from either config format are rejected below.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants