@@ -475,21 +475,16 @@ def test_run_worker_and_parse_missing_key():
475475 _run_worker_and_parse (["python" , "profiler.py" ])
476476
477477
478- def test_calculate_percentiles ():
479- from profiler import _calculate_percentiles
480- assert _calculate_percentiles ([]) == (0.0 , 0.0 , 0.0 )
481- assert _calculate_percentiles ([5.0 ]) == (5.0 , 5.0 , 5.0 )
482- p50 , p90 , p99 = _calculate_percentiles (list (range (100 )))
483- assert p50 < p90 < p99
484-
485-
486- def test_print_outputs_empty ():
478+ def test_print_outputs_multiple_and_empty ():
487479 from profiler import _print_outputs
488480 with patch ("builtins.print" ) as mock_print :
489- _print_outputs ("math" , 1 , 10 , 500 , [], 0 , 0 , 0 , [], 0 , 0 , 0 , [], 0 , 0 , 0 )
481+ _print_outputs ("math" , 1 , 10 , 500 , [], [], [])
482+ _print_outputs ("math" , 2 , 10 , 500 , [10.0 , 12.0 ], [1.0 , 2.0 ], [1.0 , 2.0 ])
490483 assert mock_print .called
491484
492485
486+
487+
493488def test_run_master_invalid_iterations ():
494489 with pytest .raises (ValueError , match = "Number of iterations must be at least 1" ):
495490 run_master (0 , "math" )
@@ -644,6 +639,7 @@ def test_find_module_from_package_metadata_init():
644639
645640
646641def test_find_module_from_package_setuptools ():
642+ sys .modules .setdefault ("setuptools" , MagicMock ())
647643 with patch ("importlib.metadata.files" , side_effect = Exception ), \
648644 patch ("os.path.exists" , return_value = True ), \
649645 patch ("setuptools.find_namespace_packages" , return_value = ["google" , "google.cloud" , "tests.dummy" , "my_pkg" ]), \
@@ -653,8 +649,8 @@ def test_find_module_from_package_setuptools():
653649 assert res == "my_pkg"
654650
655651
656-
657652def test_find_module_from_package_setuptools_not_file_and_exception ():
653+ sys .modules .setdefault ("setuptools" , MagicMock ())
658654 def mock_isfile (path ):
659655 if "a_pkg" in path :
660656 return False
@@ -675,9 +671,8 @@ def mock_isfile(path):
675671 assert res == "my.pkg"
676672
677673
678-
679-
680674def test_find_module_from_package_exception_in_find_spec ():
675+ sys .modules .setdefault ("setuptools" , MagicMock ())
681676 def mock_find_spec (mod ):
682677 raise Exception ("Find spec error" )
683678
@@ -688,6 +683,7 @@ def mock_find_spec(mod):
688683 assert res == "foo.bar"
689684
690685
686+
691687def test_cli_main_options ():
692688 import runpy
693689
0 commit comments