Skip to content

unittest -v adds one to the verbosity given to unittest.main() #163004

Backlog

Description

@fedonman

Bug description:

Since GH-155377 (gh-108885), a single -v adds one to the verbosity passed to unittest.main() instead of meaning 2. With unittest.main(verbosity=2), the form the docs use, -v now gives 3, so every doctest example is printed, which the docs say only -vv does. With verbosity=0, -v gives 1 and prints dots instead of test names.

import unittest
class T(unittest.TestCase):
    def test(self): pass
for default in 0, 1, 2:
    p = unittest.main(argv=['prog', '-v'], verbosity=default, exit=False)
    print(f'main(verbosity={default}) -v ->', p.verbosity)
$ python repro.py 2>/dev/null
main(verbosity=0) -v -> 1
main(verbosity=1) -v -> 2
main(verbosity=2) -v -> 3

3.15 prints 2 for all three:

main(verbosity=0) -v -> 2
main(verbosity=1) -v -> 2
main(verbosity=2) -v -> 2

Expected: -v gives 2 and -vv gives 3 whatever verbosity unittest.main() was given.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    stdlib
    type-bug
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions