@@ -241,8 +241,9 @@ def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R:
241241 code_context = ctx_result .unwrap ()
242242 assert code_context .helper_functions [0 ].qualified_name == "AbstractCacheBackend.get_cache_or_call"
243243 assert (
244- code_context .testgen_context
245- == f'''_P = ParamSpec("_P")
244+ code_context .testgen_context .flat
245+ == f'''# file: { file_path .relative_to (project_root_path )}
246+ _P = ParamSpec("_P")
246247_KEY_T = TypeVar("_KEY_T")
247248_STORE_T = TypeVar("_STORE_T")
248249class AbstractCacheBackend(CacheBackend, Protocol[_KEY_T, _STORE_T]):
@@ -394,10 +395,11 @@ def test_bubble_sort_deps() -> None:
394395 function_to_optimize = FunctionToOptimize (
395396 function_name = "sorter_deps" , file_path = file_path , parents = [], starting_line = None , ending_line = None
396397 )
398+ project_root = file_path .parent .parent .resolve ()
397399 test_config = TestConfig (
398400 tests_root = str (file_path .parent / "tests" ),
399401 tests_project_rootdir = file_path .parent .resolve (),
400- project_root_path = file_path . parent . parent . resolve () ,
402+ project_root_path = project_root ,
401403 test_framework = "pytest" ,
402404 pytest_cmd = "pytest" ,
403405 )
@@ -409,19 +411,20 @@ def test_bubble_sort_deps() -> None:
409411 pytest .fail ()
410412 code_context = ctx_result .unwrap ()
411413 assert (
412- code_context .testgen_context
413- == """from code_to_optimize.bubble_sort_dep1_helper import dep1_comparer
414- from code_to_optimize.bubble_sort_dep2_swap import dep2_swap
415-
414+ code_context .testgen_context .flat
415+ == f"""# file: code_to_optimize/bubble_sort_dep1_helper.py
416416def dep1_comparer(arr, j: int) -> bool:
417417 return arr[j] > arr[j + 1]
418418
419+ # file: code_to_optimize/bubble_sort_dep2_swap.py
419420def dep2_swap(arr, j):
420421 temp = arr[j]
421422 arr[j] = arr[j + 1]
422423 arr[j + 1] = temp
423424
424-
425+ # file: code_to_optimize/bubble_sort_deps.py
426+ from code_to_optimize.bubble_sort_dep1_helper import dep1_comparer
427+ from code_to_optimize.bubble_sort_dep2_swap import dep2_swap
425428
426429def sorter_deps(arr):
427430 for i in range(len(arr)):
0 commit comments