Skip to content

gh-163004: Make unittest -v mean 2 whatever verbosity main() was given - #163005

Open
fedonman wants to merge 1 commit into
python:mainfrom
fedonman:fix-unittest-verbose-count
Open

fedonman wants to merge 1 commit into
python:mainfrom
fedonman:fix-unittest-verbose-count

Conversation

@fedonman

@fedonman fedonman commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

-v was counted up from the verbosity passed to unittest.main(), so it only meant 2 when that was 1. It is now counted separately and replaces the verbosity only when given, so -v gives 2 and -vv gives 3 whatever the default.

@efanntyo

efanntyo commented Dec 3, 2026

Copy link
Copy Markdown

The mixed -q/-v ordering may need an extra regression alongside the default-verbosity matrix. I extracted the unchanged _parse_args() and _getParentArgParser() methods from head 4e31891 and executed them with the installed Python 3.12.16 argparse (not a full PR module/build). For defaults 0, 1 and 2, the method-level probe gives:

[]          -> original default
-v          -> 2
-vv         -> 3
-q          -> 0
-q -v       -> 1
-v -q       -> 0
-q -vv      -> 2

-q stores -1 in _verbosity, so a subsequent count action increments from -1 before the final +1. In the installed 3.12 parser, -q -v gives 2 and -v -q gives 0.

Should the first -v after -q restart the verbose count, preserving that last-option behavior? A test for ['-q', '-v'] and ['-q', '-vv'] would catch the distinction; the new tests currently cover the flags separately. If mixed flags intentionally have different semantics now, documenting that would also help. AI-assisted source probe; no full main/PR build or patch-passing claim.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants