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
+
1
3
import py
2
4
import six
3
5
@@ -258,8 +260,6 @@ def _from_json(cls, reportdict):
258
260
259
261
260
262
def _report_unserialization_failure (type_name , report_class , reportdict ):
261
- from pprint import pprint
262
-
263
263
url = "https://github.com/pytest-dev/pytest/issues"
264
264
stream = py .io .TextIO ()
265
265
pprint ("-" * 100 , stream = stream )
Original file line number Diff line number Diff line change
1
+ import pytest
1
2
from _pytest .pathlib import Path
2
3
from _pytest .reports import CollectReport
3
4
from _pytest .reports import TestReport
@@ -219,6 +220,28 @@ def test_a():
219
220
assert data ["path1" ] == str (testdir .tmpdir )
220
221
assert data ["path2" ] == str (testdir .tmpdir )
221
222
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
+
222
245
223
246
class TestHooks :
224
247
"""Test that the hooks are working correctly for plugins"""
You can’t perform that action at this time.
0 commit comments