@@ -2331,6 +2331,40 @@ def deselect_by_test_model_suites(test_model_suites, items, test_prefix,
23312331 config .hook .pytest_deselected (items = deselected )
23322332 items [:] = selected
23332333
2334+ # Initialize PeriodicJUnitXML reporter if enabled
2335+ periodic = config .getoption ("--periodic-junit" , default = False )
2336+ output_dir = config .getoption ("--output-dir" , default = None )
2337+
2338+ if periodic and output_dir :
2339+ periodic_interval = config .getoption ("--periodic-interval" )
2340+ periodic_batch_size = config .getoption ("--periodic-batch-size" )
2341+
2342+ # Create the reporter with logger
2343+ xmlpath = os .path .join (output_dir , "results.xml" )
2344+ reporter = PeriodicJUnitXML (
2345+ xmlpath = xmlpath ,
2346+ interval = periodic_interval ,
2347+ batch_size = periodic_batch_size ,
2348+ logger = {
2349+ 'info' : print_info ,
2350+ 'warning' : print_warning
2351+ },
2352+ )
2353+
2354+ # Configure and register the reporter
2355+ reporter .pytest_configure (config )
2356+ config .pluginmanager .register (reporter , 'periodic_junit' )
2357+
2358+ print_info ("PeriodicJUnitXML reporter registered" )
2359+ print_info (
2360+ f" Interval: { periodic_interval } s ({ periodic_interval / 60 :.1f} min)"
2361+ )
2362+ print_info (f" Batch size: { periodic_batch_size } tests" )
2363+ elif periodic and not output_dir :
2364+ print_warning (
2365+ "Warning: --periodic-junit requires --output-dir to be set. "
2366+ "Periodic reporting disabled." )
2367+
23342368
23352369def deselect_by_test_model_suites (test_model_suites , items , test_prefix ,
23362370 config ):
0 commit comments