@@ -42,7 +42,7 @@ def test_example_test_3(self):
4242class MyClass:
4343 def __init__(self):
4444 self.x = 2
45- print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir !s } ')}}|TEST_INFO_END")
45+ print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir . as_posix () } ')}}|TEST_INFO_END")
4646"""
4747 test_file_name = "test_stack_info_temp.py"
4848
@@ -117,7 +117,7 @@ def test_example_test_3(self):
117117class MyClass:
118118 def __init__(self):
119119 self.x = 2
120- print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir !s } ')}}|TEST_INFO_END")
120+ print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir . as_posix () } ')}}|TEST_INFO_END")
121121"""
122122 test_file_name = "test_stack_info_temp.py"
123123
@@ -181,7 +181,7 @@ def test_example_test_3(self):
181181class MyClass:
182182 def __init__(self):
183183 self.x = 2
184- print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir !s } ')}}|TEST_INFO_END")
184+ print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir . as_posix () } ')}}|TEST_INFO_END")
185185"""
186186 test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
187187 test_file_name = "test_stack_info_temp.py"
@@ -261,7 +261,7 @@ class MyClass:
261261 def __init__(self):
262262 self.x = 2
263263 # Print out the detected test info each time we instantiate MyClass
264- print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir !s } ')}}|TEST_INFO_END")
264+ print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir . as_posix () } ')}}|TEST_INFO_END")
265265"""
266266
267267 test_file_name = "test_stack_info_recursive_temp.py"
@@ -343,7 +343,7 @@ def test_example_test():
343343class MyClass:
344344 def __init__(self):
345345 self.x = 2
346- print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir !s } ')}}|TEST_INFO_END")
346+ print(f"TEST_INFO_START|{{get_test_info_from_stack('{ test_dir . as_posix () } ')}}|TEST_INFO_END")
347347"""
348348 test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
349349 test_file_name = "test_stack_info_temp.py"
@@ -410,10 +410,11 @@ def test_example_test_3(self):
410410 self.assertTrue(True)
411411 """
412412 test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
413+ tmp_dir_path = get_run_tmp_file (Path ("test_return_values" ))
413414 sample_code = f"""
414415from codeflash.verification.codeflash_capture import codeflash_capture
415416class MyClass:
416- @codeflash_capture(function_name="some_function", tmp_dir_path="{ get_run_tmp_file ( Path ( "test_return_values" )) } ", tests_root="{ test_dir !s } ")
417+ @codeflash_capture(function_name="some_function", tmp_dir_path="{ tmp_dir_path . as_posix () } ", tests_root="{ test_dir . as_posix () } ")
417418 def __init__(self, x=2):
418419 self.x = x
419420 """
@@ -528,6 +529,7 @@ def test_example_test_3(self):
528529 self.assertTrue(True)
529530 """
530531 test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
532+ tmp_dir_path = get_run_tmp_file (Path ("test_return_values" ))
531533 # MyClass did not have an init function, we created the init function with the codeflash_capture decorator using instrumentation
532534 sample_code = f"""
533535from codeflash.verification.codeflash_capture import codeflash_capture
@@ -536,7 +538,7 @@ def __init__(self):
536538 self.x = 2
537539
538540class MyClass(ParentClass):
539- @codeflash_capture(function_name="some_function", tmp_dir_path="{ get_run_tmp_file ( Path ( "test_return_values" )) } ", tests_root="{ test_dir !s } ")
541+ @codeflash_capture(function_name="some_function", tmp_dir_path="{ tmp_dir_path . as_posix () } ", tests_root="{ test_dir . as_posix () } ")
540542 def __init__(self, *args, **kwargs):
541543 super().__init__(*args, **kwargs)
542544 """
@@ -648,14 +650,15 @@ def test_example_test():
648650
649651"""
650652 test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
653+ tmp_dir_path = get_run_tmp_file (Path ("test_return_values" ))
651654 sample_code = f"""
652655from codeflash.verification.codeflash_capture import codeflash_capture
653656
654657class MyClass:
655658 @codeflash_capture(
656659 function_name="some_function",
657- tmp_dir_path="{ get_run_tmp_file ( Path ( "test_return_values" ) )} ",
658- tests_root="{ test_dir !s } "
660+ tmp_dir_path="{ tmp_dir_path . as_posix ( )} ",
661+ tests_root="{ test_dir . as_posix () } "
659662 )
660663 def __init__(self, x=2):
661664 self.x = x
@@ -765,13 +768,14 @@ def test_helper_classes():
765768 assert MyClass().target_function() == 6
766769"""
767770 test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
771+ tmp_dir_path = get_run_tmp_file (Path ("test_return_values" ))
768772 original_code = f"""
769773from codeflash.verification.codeflash_capture import codeflash_capture
770774from code_to_optimize.tests.pytest.helper_file_1 import HelperClass1
771775from code_to_optimize.tests.pytest.helper_file_2 import HelperClass2, AnotherHelperClass
772776
773777class MyClass:
774- @codeflash_capture(function_name='MyClass.__init__', tmp_dir_path='{ get_run_tmp_file ( Path ( "test_return_values" )) } ', tests_root="{ test_dir !s } " , is_fto=True)
778+ @codeflash_capture(function_name='MyClass.__init__', tmp_dir_path='{ tmp_dir_path . as_posix () } ', tests_root="{ test_dir . as_posix () } " , is_fto=True)
775779 def __init__(self):
776780 self.x = 1
777781
@@ -785,7 +789,7 @@ def target_function(self):
785789from codeflash.verification.codeflash_capture import codeflash_capture
786790
787791class HelperClass1:
788- @codeflash_capture(function_name='HelperClass1.__init__', tmp_dir_path='{ get_run_tmp_file ( Path ( "test_return_values" )) } ', tests_root="{ test_dir !s } ", is_fto=False)
792+ @codeflash_capture(function_name='HelperClass1.__init__', tmp_dir_path='{ tmp_dir_path . as_posix () } ', tests_root="{ test_dir . as_posix () } ", is_fto=False)
789793 def __init__(self):
790794 self.y = 1
791795
@@ -797,15 +801,15 @@ def helper1(self):
797801from codeflash.verification.codeflash_capture import codeflash_capture
798802
799803class HelperClass2:
800- @codeflash_capture(function_name='HelperClass2.__init__', tmp_dir_path='{ get_run_tmp_file ( Path ( "test_return_values" )) } ', tests_root="{ test_dir !s } ", is_fto=False)
804+ @codeflash_capture(function_name='HelperClass2.__init__', tmp_dir_path='{ tmp_dir_path . as_posix () } ', tests_root="{ test_dir . as_posix () } ", is_fto=False)
801805 def __init__(self):
802806 self.z = 2
803807
804808 def helper2(self):
805809 return 2
806810
807811class AnotherHelperClass:
808- @codeflash_capture(function_name='AnotherHelperClass.__init__', tmp_dir_path='{ get_run_tmp_file ( Path ( "test_return_values" )) } ', tests_root="{ test_dir !s } ", is_fto=False)
812+ @codeflash_capture(function_name='AnotherHelperClass.__init__', tmp_dir_path='{ tmp_dir_path . as_posix () } ', tests_root="{ test_dir . as_posix () } ", is_fto=False)
809813 def __init__(self, *args, **kwargs):
810814 super().__init__(*args, **kwargs)
811815
0 commit comments