|
19 | 19 | EXIT_USAGEERROR, EXIT_NOTESTSCOLLECTED
|
20 | 20 |
|
21 | 21 |
|
| 22 | +import argparse |
| 23 | + |
| 24 | +class MoreQuietAction(argparse.Action): |
| 25 | + def __init__(self, |
| 26 | + option_strings, |
| 27 | + dest, |
| 28 | + default=None, |
| 29 | + required=False, |
| 30 | + help=None): |
| 31 | + super(MoreQuietAction, self).__init__( |
| 32 | + option_strings=option_strings, |
| 33 | + dest=dest, |
| 34 | + nargs=0, |
| 35 | + default=default, |
| 36 | + required=required, |
| 37 | + help=help) |
| 38 | + |
| 39 | + def __call__(self, parser, namespace, values, option_string=None): |
| 40 | + new_count = getattr(namespace, self.dest, 0) - 1 |
| 41 | + setattr(namespace, self.dest, new_count) |
| 42 | + # todo Deprecate config.quiet |
| 43 | + namespace.quiet = getattr(namespace, 'quiet', 0) + 1 |
| 44 | + |
| 45 | + |
22 | 46 | def pytest_addoption(parser):
|
23 | 47 | group = parser.getgroup("terminal reporting", "reporting", after="general")
|
24 | 48 | group._addoption('-v', '--verbose', action="count",
|
25 |
| - dest="verbose", default=0, help="increase verbosity."), |
26 |
| - group._addoption('-q', '--quiet', action="count", |
27 |
| - dest="quiet", default=0, help="decrease verbosity."), |
| 49 | + dest="verbose", help="increase verbosity."), |
| 50 | + group._addoption('-q', '--quiet', action=MoreQuietAction, |
| 51 | + dest="verbose", help="decrease verbosity."), |
| 52 | + group.addoption("--verbosity", dest='verbose', type=int, |
| 53 | + help="set verbosity") |
28 | 54 | group._addoption('-r',
|
29 | 55 | action="store", dest="reportchars", default='', metavar="chars",
|
30 | 56 | help="show extra test summary info as specified by chars (f)ailed, "
|
@@ -61,7 +87,6 @@ def pytest_addoption(parser):
|
61 | 87 |
|
62 | 88 |
|
63 | 89 | def pytest_configure(config):
|
64 |
| - config.option.verbose -= config.option.quiet |
65 | 90 | reporter = TerminalReporter(config, sys.stdout)
|
66 | 91 | config.pluginmanager.register(reporter, 'terminalreporter')
|
67 | 92 | if config.option.debug or config.option.traceconfig:
|
|
0 commit comments