Merge pull request #171 from timyhou/longrepr.sections_issue

Serialization/Deserialization was dropping longrepr.sections
This commit is contained in:
Bruno Oliveira
2017-06-28 18:31:19 -03:00
committed by GitHub
4 changed files with 11 additions and 2 deletions

1
changelog/pr_171.bugfix Normal file
View File

@@ -0,0 +1 @@
Forgot to serialize and deserialize the longrepr.sections attribute.

View File

@@ -87,11 +87,14 @@ class TestReportSerialization:
reports = reprec.getreports("pytest_runtest_logreport")
assert len(reports) == 3
initial_failure_report = reports[1]
added_section = ('Failure Metadata', str("metadata metadata"), "*")
initial_failure_report.longrepr.sections.append(added_section)
d = serialize_report(initial_failure_report)
check_marshallable(d)
processed_report = unserialize_report("testreport", d)
assert 'Expected Message' \
in processed_report.longrepr.reprcrash.message
assert added_section in processed_report.longrepr.sections
def test_itemreport_outcomes(self, testdir):
reprec = testdir.inline_runsource("""

View File

@@ -114,7 +114,8 @@ def serialize_report(rep):
return {
'reprcrash': reprcrash,
'reprtraceback': reprtraceback
'reprtraceback': reprtraceback,
'sections': rep.longrepr.sections
}
import py

View File

@@ -359,10 +359,14 @@ def unserialize_report(name, reportdict):
unserialized_entries.append(reprentry)
reprtraceback['reprentries'] = unserialized_entries
reportdict['longrepr'] = ReprExceptionInfo(
exception_info = ReprExceptionInfo(
reprtraceback=ReprTraceback(**reprtraceback),
reprcrash=ReprFileLocation(**reprcrash),
)
for section in reportdict['longrepr']['sections']:
exception_info.addsection(*section)
reportdict['longrepr'] = exception_info
return reportdict
if name == "testreport":