Merge pull request #202 from nicoddemus/traceback-error
Fix serialization of native tracebacks
This commit is contained in:
@@ -671,6 +671,20 @@ def test_worker_id_fixture(testdir, n):
|
||||
assert worker_ids == set(['gw0', 'gw1'])
|
||||
|
||||
|
||||
@pytest.mark.parametrize('tb',
|
||||
['auto', 'long', 'short', 'no', 'line', 'native'])
|
||||
def test_error_report_styles(testdir, tb):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
def test_error_report_styles():
|
||||
raise RuntimeError('some failure happened')
|
||||
""")
|
||||
result = testdir.runpytest('-n1', '--tb=%s' % tb)
|
||||
if tb != 'no':
|
||||
result.stdout.fnmatch_lines('*some failure happened*')
|
||||
result.assert_outcomes(failed=1)
|
||||
|
||||
|
||||
def test_color_yes_collection_on_non_atty(testdir, request):
|
||||
"""skip collect progress report when working on non-terminals.
|
||||
|
||||
|
||||
@@ -113,11 +113,12 @@ class TestReportSerialization:
|
||||
assert added_section in a.longrepr.sections
|
||||
|
||||
def test_reprentries_serialization_170(self, testdir):
|
||||
from _pytest._code.code import ReprEntry
|
||||
reprec = testdir.inline_runsource("""
|
||||
def test_fail():
|
||||
def test_repr_entry():
|
||||
x = 0
|
||||
assert x
|
||||
""", '--showlocals', '-n1')
|
||||
""", '--showlocals')
|
||||
reports = reprec.getreports("pytest_runtest_logreport")
|
||||
assert len(reports) == 3
|
||||
rep = reports[1]
|
||||
@@ -128,6 +129,7 @@ class TestReportSerialization:
|
||||
a_entries = a.longrepr.reprtraceback.reprentries
|
||||
assert rep_entries == a_entries
|
||||
for i in range(len(a_entries)):
|
||||
assert isinstance(rep_entries[i], ReprEntry)
|
||||
assert rep_entries[i].lines == a_entries[i].lines
|
||||
assert rep_entries[i].localssep == a_entries[i].localssep
|
||||
assert rep_entries[i].reprfileloc == a_entries[i].reprfileloc
|
||||
@@ -135,6 +137,26 @@ class TestReportSerialization:
|
||||
assert rep_entries[i].reprlocals == a_entries[i].reprlocals
|
||||
assert rep_entries[i].style == a_entries[i].style
|
||||
|
||||
def test_reprentries_serialization_196(self, testdir):
|
||||
from _pytest._code.code import ReprEntryNative
|
||||
reprec = testdir.inline_runsource("""
|
||||
def test_repr_entry_native():
|
||||
x = 0
|
||||
assert x
|
||||
""", '--tb=native')
|
||||
reports = reprec.getreports("pytest_runtest_logreport")
|
||||
assert len(reports) == 3
|
||||
rep = reports[1]
|
||||
d = serialize_report(rep)
|
||||
a = unserialize_report("testreport", d)
|
||||
|
||||
rep_entries = rep.longrepr.reprtraceback.reprentries
|
||||
a_entries = a.longrepr.reprtraceback.reprentries
|
||||
assert rep_entries == a_entries
|
||||
for i in range(len(a_entries)):
|
||||
assert isinstance(rep_entries[i], ReprEntryNative)
|
||||
assert rep_entries[i].lines == a_entries[i].lines
|
||||
|
||||
def test_itemreport_outcomes(self, testdir):
|
||||
reprec = testdir.inline_runsource("""
|
||||
import py
|
||||
|
||||
Reference in New Issue
Block a user