@@ -680,8 +680,14 @@ def test_in_dunder_tests():
680680
681681 # Combine all discovered functions
682682 all_functions = {}
683- for discovered in [discovered_source , discovered_test , discovered_test_underscore ,
684- discovered_spec , discovered_tests_dir , discovered_dunder_tests ]:
683+ for discovered in [
684+ discovered_source ,
685+ discovered_test ,
686+ discovered_test_underscore ,
687+ discovered_spec ,
688+ discovered_tests_dir ,
689+ discovered_dunder_tests ,
690+ ]:
685691 all_functions .update (discovered )
686692
687693 # Test Case 1: tests_root == module_root (overlapping case)
@@ -781,9 +787,7 @@ def test_filter_functions_strict_string_matching():
781787
782788 # Strict check: exactly these 3 files should remain (those with 'test' as substring only)
783789 expected_files = {contest_file , latest_file , attestation_file }
784- assert set (filtered .keys ()) == expected_files , (
785- f"Expected files { expected_files } , got { set (filtered .keys ())} "
786- )
790+ assert set (filtered .keys ()) == expected_files , f"Expected files { expected_files } , got { set (filtered .keys ())} "
787791
788792 # Strict check: each file should have exactly 1 function with the expected name
789793 assert [fn .function_name for fn in filtered [contest_file ]] == ["run_contest" ], (
@@ -871,9 +875,7 @@ def test_filter_functions_test_directory_patterns():
871875
872876 # Strict check: exactly these 2 files should remain (those in non-test directories)
873877 expected_files = {contest_file , latest_file }
874- assert set (filtered .keys ()) == expected_files , (
875- f"Expected files { expected_files } , got { set (filtered .keys ())} "
876- )
878+ assert set (filtered .keys ()) == expected_files , f"Expected files { expected_files } , got { set (filtered .keys ())} "
877879
878880 # Strict check: each file should have exactly 1 function with the expected name
879881 assert [fn .function_name for fn in filtered [contest_file ]] == ["get_scores" ], (
@@ -936,9 +938,7 @@ def test_filter_functions_non_overlapping_tests_root():
936938
937939 # Strict check: exactly these 2 files should remain (both in src/, not in tests/)
938940 expected_files = {source_file , test_in_src }
939- assert set (filtered .keys ()) == expected_files , (
940- f"Expected files { expected_files } , got { set (filtered .keys ())} "
941- )
941+ assert set (filtered .keys ()) == expected_files , f"Expected files { expected_files } , got { set (filtered .keys ())} "
942942
943943 # Strict check: each file should have exactly 1 function with the expected name
944944 assert [fn .function_name for fn in filtered [source_file ]] == ["process" ], (
@@ -1047,20 +1047,15 @@ def test_deep_copy():
10471047 )
10481048
10491049 root_functions = [fn .function_name for fn in filtered .get (root_source_file , [])]
1050- assert root_functions == ["main" ], (
1051- f"Expected ['main'], got { root_functions } "
1052- )
1050+ assert root_functions == ["main" ], f"Expected ['main'], got { root_functions } "
10531051
10541052 # Strict check: exactly 3 functions (2 from utils.py + 1 from main.py)
10551053 assert count == 3 , (
1056- f"Expected exactly 3 functions, got { count } . "
1057- f"Some source files may have been incorrectly filtered."
1054+ f"Expected exactly 3 functions, got { count } . Some source files may have been incorrectly filtered."
10581055 )
10591056
10601057 # Verify test file was properly filtered (should not be in results)
1061- assert test_file not in filtered , (
1062- f"Test file { test_file } should have been filtered but wasn't"
1063- )
1058+ assert test_file not in filtered , f"Test file { test_file } should have been filtered but wasn't"
10641059
10651060
10661061def test_filter_functions_typescript_project_in_tests_folder ():
@@ -1214,9 +1209,7 @@ def sample_data():
12141209 # source_file and file_in_test_dir should remain
12151210 # test_prefix_file, conftest_file, and test_in_subdir should be filtered
12161211 expected_files = {source_file , file_in_test_dir }
1217- assert set (filtered .keys ()) == expected_files , (
1218- f"Expected { expected_files } , got { set (filtered .keys ())} "
1219- )
1212+ assert set (filtered .keys ()) == expected_files , f"Expected { expected_files } , got { set (filtered .keys ())} "
12201213 assert count == 2 , f"Expected exactly 2 functions, got { count } "
12211214
12221215
@@ -1266,7 +1259,8 @@ def helper_method(self):
12661259""" )
12671260
12681261 support = PythonSupport ()
1269- functions = support .discover_functions (fixture_file )
1262+ source = fixture_file .read_text (encoding = "utf-8" )
1263+ functions = support .discover_functions (source , fixture_file )
12701264 function_names = [fn .function_name for fn in functions ]
12711265
12721266 assert "regular_function" in function_names
0 commit comments