@@ -249,7 +249,6 @@ class TestHooks:
249
249
def test_test_report (self , testdir , pytestconfig ):
250
250
testdir .makepyfile (
251
251
"""
252
- import os
253
252
def test_a(): assert False
254
253
def test_b(): pass
255
254
"""
@@ -272,7 +271,6 @@ def test_b(): pass
272
271
def test_collect_report (self , testdir , pytestconfig ):
273
272
testdir .makepyfile (
274
273
"""
275
- import os
276
274
def test_a(): assert False
277
275
def test_b(): pass
278
276
"""
@@ -291,3 +289,25 @@ def test_b(): pass
291
289
assert new_rep .nodeid == rep .nodeid
292
290
assert new_rep .when == "collect"
293
291
assert new_rep .outcome == rep .outcome
292
+
293
+ @pytest .mark .parametrize (
294
+ "hook_name" , ["pytest_runtest_logreport" , "pytest_collectreport" ]
295
+ )
296
+ def test_invalid_report_types (self , testdir , pytestconfig , hook_name ):
297
+ testdir .makepyfile (
298
+ """
299
+ def test_a(): pass
300
+ """
301
+ )
302
+ reprec = testdir .inline_run ()
303
+ reports = reprec .getreports (hook_name )
304
+ assert reports
305
+ rep = reports [0 ]
306
+ data = pytestconfig .hook .pytest_report_serialize (
307
+ config = pytestconfig , report = rep
308
+ )
309
+ data ["_report_type" ] = "Unknown"
310
+ with pytest .raises (AssertionError ):
311
+ _ = pytestconfig .hook .pytest_report_unserialize (
312
+ config = pytestconfig , data = data
313
+ )
0 commit comments