@@ -42,7 +42,7 @@ def test_example_test_3(self):
42
42
class MyClass:
43
43
def __init__(self):
44
44
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")
46
46
"""
47
47
test_file_name = "test_stack_info_temp.py"
48
48
@@ -117,7 +117,7 @@ def test_example_test_3(self):
117
117
class MyClass:
118
118
def __init__(self):
119
119
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")
121
121
"""
122
122
test_file_name = "test_stack_info_temp.py"
123
123
@@ -181,7 +181,7 @@ def test_example_test_3(self):
181
181
class MyClass:
182
182
def __init__(self):
183
183
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")
185
185
"""
186
186
test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
187
187
test_file_name = "test_stack_info_temp.py"
@@ -261,7 +261,7 @@ class MyClass:
261
261
def __init__(self):
262
262
self.x = 2
263
263
# 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")
265
265
"""
266
266
267
267
test_file_name = "test_stack_info_recursive_temp.py"
@@ -343,7 +343,7 @@ def test_example_test():
343
343
class MyClass:
344
344
def __init__(self):
345
345
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")
347
347
"""
348
348
test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
349
349
test_file_name = "test_stack_info_temp.py"
@@ -410,10 +410,11 @@ def test_example_test_3(self):
410
410
self.assertTrue(True)
411
411
"""
412
412
test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
413
+ tmp_dir_path = get_run_tmp_file (Path ("test_return_values" ))
413
414
sample_code = f"""
414
415
from codeflash.verification.codeflash_capture import codeflash_capture
415
416
class 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 () } ")
417
418
def __init__(self, x=2):
418
419
self.x = x
419
420
"""
@@ -528,6 +529,7 @@ def test_example_test_3(self):
528
529
self.assertTrue(True)
529
530
"""
530
531
test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
532
+ tmp_dir_path = get_run_tmp_file (Path ("test_return_values" ))
531
533
# MyClass did not have an init function, we created the init function with the codeflash_capture decorator using instrumentation
532
534
sample_code = f"""
533
535
from codeflash.verification.codeflash_capture import codeflash_capture
@@ -536,7 +538,7 @@ def __init__(self):
536
538
self.x = 2
537
539
538
540
class 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 () } ")
540
542
def __init__(self, *args, **kwargs):
541
543
super().__init__(*args, **kwargs)
542
544
"""
@@ -648,14 +650,15 @@ def test_example_test():
648
650
649
651
"""
650
652
test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
653
+ tmp_dir_path = get_run_tmp_file (Path ("test_return_values" ))
651
654
sample_code = f"""
652
655
from codeflash.verification.codeflash_capture import codeflash_capture
653
656
654
657
class MyClass:
655
658
@codeflash_capture(
656
659
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 () } "
659
662
)
660
663
def __init__(self, x=2):
661
664
self.x = x
@@ -765,13 +768,14 @@ def test_helper_classes():
765
768
assert MyClass().target_function() == 6
766
769
"""
767
770
test_dir = (Path (__file__ ).parent .parent / "code_to_optimize" / "tests" / "pytest" ).resolve ()
771
+ tmp_dir_path = get_run_tmp_file (Path ("test_return_values" ))
768
772
original_code = f"""
769
773
from codeflash.verification.codeflash_capture import codeflash_capture
770
774
from code_to_optimize.tests.pytest.helper_file_1 import HelperClass1
771
775
from code_to_optimize.tests.pytest.helper_file_2 import HelperClass2, AnotherHelperClass
772
776
773
777
class 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)
775
779
def __init__(self):
776
780
self.x = 1
777
781
@@ -785,7 +789,7 @@ def target_function(self):
785
789
from codeflash.verification.codeflash_capture import codeflash_capture
786
790
787
791
class 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)
789
793
def __init__(self):
790
794
self.y = 1
791
795
@@ -797,15 +801,15 @@ def helper1(self):
797
801
from codeflash.verification.codeflash_capture import codeflash_capture
798
802
799
803
class 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)
801
805
def __init__(self):
802
806
self.z = 2
803
807
804
808
def helper2(self):
805
809
return 2
806
810
807
811
class 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)
809
813
def __init__(self, *args, **kwargs):
810
814
super().__init__(*args, **kwargs)
811
815
0 commit comments