-
-
Notifications
You must be signed in to change notification settings - Fork 505
/
test_parse.py
41 lines (29 loc) · 1.03 KB
/
test_parse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import annotations
import logging
import pytest
from tox.config.cli.parse import get_options
from tox.pytest import CaptureFixture
def test_help_does_not_default_cmd(capsys: CaptureFixture) -> None:
with pytest.raises(SystemExit):
get_options("-h")
out, err = capsys.readouterr()
assert not err
assert "--verbose" in out
assert "subcommands:" in out
def test_verbosity_guess_miss_match(capsys: CaptureFixture) -> None:
result = get_options("-rv")
assert result.parsed.verbosity == 3
assert logging.getLogger().level == logging.INFO
for name in ("distlib.util", "filelock"):
logger = logging.getLogger(name)
assert logger.disabled
logging.error("E")
logging.warning("W")
logging.info("I")
logging.debug("D")
out, err = capsys.readouterr()
assert out == "ROOT: E\nROOT: W\nROOT: I\n"
@pytest.mark.parametrize("arg", ["-av", "-va"])
def test_verbosity(arg: str) -> None:
result = get_options(arg)
assert result.parsed.verbosity == 3