Merge pull request #6125 from blueyed/upstream-test_terminal-fulltrace

test_terminal: reduce number of tests (single --fulltrace param)
This commit is contained in:
Daniel Hahler 2019-11-04 11:50:18 +01:00 committed by GitHub
commit d53794f916
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 14 deletions

View File

@ -24,27 +24,19 @@ DistInfo = collections.namedtuple("DistInfo", ["project_name", "version"])
class Option:
def __init__(self, verbosity=0, fulltrace=False):
def __init__(self, verbosity=0):
self.verbosity = verbosity
self.fulltrace = fulltrace
@property
def args(self):
values = []
values.append("--verbosity=%d" % self.verbosity)
if self.fulltrace:
values.append("--fulltrace")
return values
@pytest.fixture(
params=[
Option(verbosity=0),
Option(verbosity=1),
Option(verbosity=-1),
Option(fulltrace=True),
],
ids=["default", "verbose", "quiet", "fulltrace"],
params=[Option(verbosity=0), Option(verbosity=1), Option(verbosity=-1)],
ids=["default", "verbose", "quiet"],
)
def option(request):
return request.param
@ -207,7 +199,8 @@ class TestTerminal:
result.stdout.fnmatch_lines(["*a123/test_hello123.py*PASS*"])
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(
"""
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(
[
" def test_foobar():",
@ -228,7 +221,7 @@ class TestTerminal:
"*_keyboard_interrupt.py:6: KeyboardInterrupt*",
]
)
if option.fulltrace:
if fulltrace:
result.stdout.fnmatch_lines(
["*raise KeyboardInterrupt # simulating the user*"]
)