test_terminal: reduce number of tests (single --fulltrace param)
Remove the `--fulltrace` arg from the `Option` fixture used in several tests, but not checked for. Only use it with `test_keyboard_interrupt`. (removes 8 tests, coverage not affected)
This commit is contained in:
parent
9303de877a
commit
9f800b2a77
|
@ -24,27 +24,19 @@ DistInfo = collections.namedtuple("DistInfo", ["project_name", "version"])
|
||||||
|
|
||||||
|
|
||||||
class Option:
|
class Option:
|
||||||
def __init__(self, verbosity=0, fulltrace=False):
|
def __init__(self, verbosity=0):
|
||||||
self.verbosity = verbosity
|
self.verbosity = verbosity
|
||||||
self.fulltrace = fulltrace
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def args(self):
|
def args(self):
|
||||||
values = []
|
values = []
|
||||||
values.append("--verbosity=%d" % self.verbosity)
|
values.append("--verbosity=%d" % self.verbosity)
|
||||||
if self.fulltrace:
|
|
||||||
values.append("--fulltrace")
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(
|
@pytest.fixture(
|
||||||
params=[
|
params=[Option(verbosity=0), Option(verbosity=1), Option(verbosity=-1)],
|
||||||
Option(verbosity=0),
|
ids=["default", "verbose", "quiet"],
|
||||||
Option(verbosity=1),
|
|
||||||
Option(verbosity=-1),
|
|
||||||
Option(fulltrace=True),
|
|
||||||
],
|
|
||||||
ids=["default", "verbose", "quiet", "fulltrace"],
|
|
||||||
)
|
)
|
||||||
def option(request):
|
def option(request):
|
||||||
return request.param
|
return request.param
|
||||||
|
@ -207,7 +199,8 @@ class TestTerminal:
|
||||||
result.stdout.fnmatch_lines(["*a123/test_hello123.py*PASS*"])
|
result.stdout.fnmatch_lines(["*a123/test_hello123.py*PASS*"])
|
||||||
result.stdout.no_fnmatch_line("* <- *")
|
result.stdout.no_fnmatch_line("* <- *")
|
||||||
|
|
||||||
def test_keyboard_interrupt(self, testdir, option):
|
@pytest.mark.parametrize("fulltrace", ("", "--fulltrace"))
|
||||||
|
def test_keyboard_interrupt(self, testdir, fulltrace):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
def test_foobar():
|
def test_foobar():
|
||||||
|
@ -219,7 +212,7 @@ class TestTerminal:
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
result = testdir.runpytest(*option.args, no_reraise_ctrlc=True)
|
result = testdir.runpytest(fulltrace, no_reraise_ctrlc=True)
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
[
|
[
|
||||||
" def test_foobar():",
|
" def test_foobar():",
|
||||||
|
@ -228,7 +221,7 @@ class TestTerminal:
|
||||||
"*_keyboard_interrupt.py:6: KeyboardInterrupt*",
|
"*_keyboard_interrupt.py:6: KeyboardInterrupt*",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
if option.fulltrace:
|
if fulltrace:
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
["*raise KeyboardInterrupt # simulating the user*"]
|
["*raise KeyboardInterrupt # simulating the user*"]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue