diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2019-03-25 19:26:40 -0300 |
---|---|---|
committer | Bruno Oliveira <nicoddemus@gmail.com> | 2019-03-25 20:16:59 -0300 |
commit | 2d77018d1b0b3c1c291bacf48885321c8c87048f (patch) | |
tree | 992916e28cf38a75d6315c16ca20cd94c649c6ff /testing/test_reports.py | |
parent | ceef0af1aea4c8db3b8670a2ff4f127a56028bb4 (diff) | |
download | pytest-2d77018d1b0b3c1c291bacf48885321c8c87048f.tar.gz |
Improve coverage for _report_unserialization_failure
Diffstat (limited to 'testing/test_reports.py')
-rw-r--r-- | testing/test_reports.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testing/test_reports.py b/testing/test_reports.py index 2f9162e10..879a9098d 100644 --- a/testing/test_reports.py +++ b/testing/test_reports.py @@ -1,3 +1,4 @@ +import pytest from _pytest.pathlib import Path from _pytest.reports import CollectReport from _pytest.reports import TestReport @@ -219,6 +220,28 @@ class TestReportSerialization(object): assert data["path1"] == str(testdir.tmpdir) assert data["path2"] == str(testdir.tmpdir) + def test_unserialization_failure(self, testdir): + """Check handling of failure during unserialization of report types.""" + testdir.makepyfile( + """ + def test_a(): + assert False + """ + ) + reprec = testdir.inline_run() + reports = reprec.getreports("pytest_runtest_logreport") + assert len(reports) == 3 + test_a_call = reports[1] + data = test_a_call._to_json() + entry = data["longrepr"]["reprtraceback"]["reprentries"][0] + assert entry["type"] == "ReprEntry" + + entry["type"] = "Unknown" + with pytest.raises( + RuntimeError, match="INTERNALERROR: Unknown entry type returned: Unknown" + ): + TestReport._from_json(data) + class TestHooks: """Test that the hooks are working correctly for plugins""" |