@@ -469,12 +469,14 @@ def test_dry_run_default(self, mock_default_dirs):
469469
470470 def test_timing_flag (self , mock_default_dirs ):
471471 """Test that --timing flag is parsed correctly."""
472+ # pylint: disable=unused-argument
472473 with patch ("sys.argv" , ["relink.py" , "--timing" ]):
473474 args = relink .parse_arguments ()
474475 assert args .timing is True
475476
476477 def test_timing_default (self , mock_default_dirs ):
477478 """Test that timing defaults to False."""
479+ # pylint: disable=unused-argument
478480 with patch ("sys.argv" , ["relink.py" ]):
479481 args = relink .parse_arguments ()
480482 assert args .timing is False
@@ -483,8 +485,11 @@ def test_timing_default(self, mock_default_dirs):
483485class TestTiming :
484486 """Test suite for timing functionality."""
485487
486- def test_timing_message_logged (self , tmp_path , caplog ):
487- """Test that timing message is logged when timing is enabled."""
488+ @pytest .mark .parametrize (
489+ "use_timing, should_log_timing" , [(True , True ), (False , False )]
490+ )
491+ def test_timing_logging (self , tmp_path , caplog , use_timing , should_log_timing ):
492+ """Test that timing message is logged only when --timing flag is used."""
488493 # Create real directories
489494 source_dir = tmp_path / "source"
490495 target_dir = tmp_path / "target"
@@ -497,51 +502,28 @@ def test_timing_message_logged(self, tmp_path, caplog):
497502 source_file .write_text ("source" )
498503 target_file .write_text ("target" )
499504
500- # Mock sys. argv to simulate running with --timing
505+ # Build argv with or without --timing flag
501506 test_argv = [
502507 "relink.py" ,
503- "--source-root" , str (source_dir ),
504- "--target-root" , str (target_dir ),
505- "--timing"
508+ "--source-root" ,
509+ str (source_dir ),
510+ "--target-root" ,
511+ str (target_dir ),
506512 ]
513+ if use_timing :
514+ test_argv .append ("--timing" )
507515
508516 with patch ("sys.argv" , test_argv ):
509517 with caplog .at_level (logging .INFO ):
510518 # Call main() which includes the timing logic
511519 relink .main ()
512520
513- # Verify timing message was logged
514- assert "Execution time:" in caplog .text
515- assert "seconds" in caplog .text
516-
517- def test_timing_not_logged_by_default (self , tmp_path , caplog ):
518- """Test that timing message is not logged when timing is disabled."""
519- # Create real directories
520- source_dir = tmp_path / "source"
521- target_dir = tmp_path / "target"
522- source_dir .mkdir ()
523- target_dir .mkdir ()
524-
525- # Create a file
526- source_file = source_dir / "test_file.txt"
527- target_file = target_dir / "test_file.txt"
528- source_file .write_text ("source" )
529- target_file .write_text ("target" )
530-
531- # Mock sys.argv WITHOUT --timing flag
532- test_argv = [
533- "relink.py" ,
534- "--source-root" , str (source_dir ),
535- "--target-root" , str (target_dir )
536- ]
537-
538- with patch ("sys.argv" , test_argv ):
539- with caplog .at_level (logging .INFO ):
540- # Call main() without timing flag
541- relink .main ()
542-
543- # Verify timing message was NOT logged
544- assert "Execution time:" not in caplog .text
521+ # Verify timing message presence based on flag
522+ if should_log_timing :
523+ assert "Execution time:" in caplog .text
524+ assert "seconds" in caplog .text
525+ else :
526+ assert "Execution time:" not in caplog .text
545527
546528
547529class TestDryRun :
0 commit comments