1616import pytest
1717from _pytest .junitxml import xml_key
1818from pluggy ._result import _Result as Result
19- from pytest_jsonreport .plugin import JSONReport
2019
2120from utils import context
2221from utils ._context .junit_parameters import fingerprint_parameters
3029from utils .manifest import Manifest
3130from utils .properties_serialization import SetupProperties
3231
33- # Monkey patch JSON-report plugin to avoid noise in report
34- JSONReport .pytest_terminal_summary = lambda * args , ** kwargs : None # noqa: ARG005
35-
3632# pytest does not keep a trace of deselected items, so we keep it in a global variable
3733_deselected_items : list [pytest .Item ] = []
3834setup_properties = SetupProperties ()
@@ -221,7 +217,6 @@ def pytest_configure(config: pytest.Config) -> None:
221217 pytest .exit (f"Scenario { config .option .scenario } does not exist" , 1 )
222218
223219 if not config .option .replay and not config .option .collectonly :
224- config .option .json_report_file = f"{ context .scenario .host_log_folder } /report.json"
225220 config .option .xmlpath = f"{ context .scenario .host_log_folder } /reportJunit.xml"
226221
227222 configure_decorators (config )
@@ -525,15 +520,17 @@ def pytest_fixture_setup(
525520
526521
527522@pytest .hookimpl (hookwrapper = True )
528- def pytest_runtest_makereport (item : pytest .Item , call : pytest .CallInfo ) -> Generator [None , Result , None ]: # noqa: ARG001
523+ def pytest_runtest_makereport (item : pytest .Item , call : pytest .CallInfo ) -> Generator [None , Result , None ]:
524+ if call .when == "setup" :
525+ _collect_item_metadata (item )
526+
529527 # Run all other hooks to get the report object
530528 outcome = yield
531529 rep : pytest .TestReport = outcome .get_result ()
532530
533531 if rep .when == "call" : # only attach outcome after test call
534532 # rep.outcome is one of: passed, failed, skipped
535- # but json_report also distinguishes xfailed/xpassed
536- # via rep.wasxfail and outcome
533+ # xfailed/xpassed are distinguished via rep.wasxfail and outcome
537534 value = rep .outcome
538535 if getattr (rep , "wasxfail" , None ):
539536 if rep .outcome == "skipped" :
@@ -558,21 +555,6 @@ def _set_outcome_properties(outcome: PytestOutcome, user_properties: list[tuple]
558555 user_properties .append (("dd_tags[test.final_status]" , final_status ))
559556
560557
561- @pytest .hookimpl (optionalhook = True )
562- def pytest_json_runtest_metadata (item : pytest .Item , call : pytest .CallInfo ) -> dict | None :
563- if call .when != "setup" :
564- return {}
565-
566- return _collect_item_metadata (item )
567-
568-
569- def pytest_json_modifyreport (json_report : dict ) -> None :
570- # add usefull data for reporting
571- json_report ["context" ] = context .serialize ()
572-
573- logger .debug ("Modifying JSON report finished" )
574-
575-
576558def pytest_sessionfinish (session : pytest .Session , exitstatus : int ) -> None :
577559 logger .info ("Executing pytest_sessionfinish" )
578560
0 commit comments