Merge pull request #4132 from blueyed/pdb-internal-dupe

Do not print (duplicate) INTERNALERROR with --pdb.
This commit is contained in:
Daniel Hahler 2018-10-14 11:25:35 +02:00 committed by GitHub
commit 3bfaa8ab84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 11 deletions

View File

@ -0,0 +1 @@
Fix duplicate printing of internal errors when using ``--pdb``.

View File

@ -109,9 +109,6 @@ class PdbInvoke(object):
_enter_pdb(node, call.excinfo, report) _enter_pdb(node, call.excinfo, report)
def pytest_internalerror(self, excrepr, excinfo): def pytest_internalerror(self, excrepr, excinfo):
for line in str(excrepr).split("\n"):
sys.stderr.write("INTERNALERROR> %s\n" % line)
sys.stderr.flush()
tb = _postmortem_traceback(excinfo) tb = _postmortem_traceback(excinfo)
post_mortem(tb) post_mortem(tb)

View File

@ -334,8 +334,20 @@ class TestPDB(object):
) )
p1 = testdir.makepyfile("def test_func(): pass") p1 = testdir.makepyfile("def test_func(): pass")
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
# child.expect(".*import pytest.*")
child.expect("Pdb") child.expect("Pdb")
# INTERNALERROR is only displayed once via terminal reporter.
assert (
len(
[
x
for x in child.before.decode().splitlines()
if x.startswith("INTERNALERROR> Traceback")
]
)
== 1
)
child.sendeof() child.sendeof()
self.flush(child) self.flush(child)
@ -345,7 +357,7 @@ class TestPDB(object):
import pytest import pytest
def test_1(): def test_1():
i = 0 i = 0
print ("hello17") print("hello17")
pytest.set_trace() pytest.set_trace()
x = 3 x = 3
""" """
@ -383,7 +395,7 @@ class TestPDB(object):
""" """
import pytest import pytest
def test_1(capsys): def test_1(capsys):
print ("hello1") print("hello1")
pytest.set_trace() pytest.set_trace()
""" """
) )
@ -420,7 +432,7 @@ class TestPDB(object):
def test_1(): def test_1():
pdb.set_trace() pdb.set_trace()
def test_2(): def test_2():
print ("hello") print("hello")
assert 0 assert 0
""" """
) )
@ -461,10 +473,10 @@ class TestPDB(object):
import pytest import pytest
def test_1(): def test_1():
i = 0 i = 0
print ("hello17") print("hello17")
pytest.set_trace() pytest.set_trace()
x = 3 x = 3
print ("hello18") print("hello18")
pytest.set_trace() pytest.set_trace()
x = 4 x = 4
""" """
@ -525,7 +537,7 @@ class TestPDB(object):
""" """
def pytest_enter_pdb(config): def pytest_enter_pdb(config):
assert config.testing_verification == 'configured' assert config.testing_verification == 'configured'
print 'enter_pdb_hook' print('enter_pdb_hook')
def pytest_configure(config): def pytest_configure(config):
config.testing_verification = 'configured' config.testing_verification = 'configured'
@ -562,7 +574,7 @@ class TestPDB(object):
custom_pdb=""" custom_pdb="""
class CustomPdb(object): class CustomPdb(object):
def set_trace(*args, **kwargs): def set_trace(*args, **kwargs):
print 'custom set_trace>' print('custom set_trace>')
""" """
) )
p1 = testdir.makepyfile( p1 = testdir.makepyfile(