File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1+ from pprint import pprint
2+
13import py
24import six
35
@@ -258,8 +260,6 @@ def _from_json(cls, reportdict):
258260
259261
260262def _report_unserialization_failure (type_name , report_class , reportdict ):
261- from pprint import pprint
262-
263263 url = "https://github.com/pytest-dev/pytest/issues"
264264 stream = py .io .TextIO ()
265265 pprint ("-" * 100 , stream = stream )
Original file line number Diff line number Diff line change 1+ import pytest
12from _pytest .pathlib import Path
23from _pytest .reports import CollectReport
34from _pytest .reports import TestReport
@@ -219,6 +220,28 @@ def test_a():
219220 assert data ["path1" ] == str (testdir .tmpdir )
220221 assert data ["path2" ] == str (testdir .tmpdir )
221222
223+ def test_unserialization_failure (self , testdir ):
224+ """Check handling of failure during unserialization of report types."""
225+ testdir .makepyfile (
226+ """
227+ def test_a():
228+ assert False
229+ """
230+ )
231+ reprec = testdir .inline_run ()
232+ reports = reprec .getreports ("pytest_runtest_logreport" )
233+ assert len (reports ) == 3
234+ test_a_call = reports [1 ]
235+ data = test_a_call ._to_json ()
236+ entry = data ["longrepr" ]["reprtraceback" ]["reprentries" ][0 ]
237+ assert entry ["type" ] == "ReprEntry"
238+
239+ entry ["type" ] = "Unknown"
240+ with pytest .raises (
241+ RuntimeError , match = "INTERNALERROR: Unknown entry type returned: Unknown"
242+ ):
243+ TestReport ._from_json (data )
244+
222245
223246class TestHooks :
224247 """Test that the hooks are working correctly for plugins"""
You can’t perform that action at this time.
0 commit comments