Skip to content

Commit 1ab1886

Browse files
committed
create path object once
1 parent 5a47237 commit 1ab1886

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

codeflash/code_utils/codeflash_wrap_decorator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def extract_test_context_from_frame() -> tuple[str, str | None, str]:
2626

2727
function_name = frame.f_code.co_name
2828
filename = frame.f_code.co_filename
29+
filename_path = Path(filename)
2930

3031
if function_name.startswith("test_"):
3132
test_name = function_name
@@ -41,8 +42,8 @@ def extract_test_context_from_frame() -> tuple[str, str | None, str]:
4142

4243
if (
4344
frame.f_globals.get("__name__", "").startswith("test_")
44-
or Path(filename).stem.startswith("test_")
45-
or "test" in Path(filename).parts
45+
or filename_path.stem.startswith("test_")
46+
or "test" in filename_path.parts
4647
):
4748
test_module_name = frame.f_globals.get("__name__", "unknown_module")
4849

@@ -53,7 +54,7 @@ def extract_test_context_from_frame() -> tuple[str, str | None, str]:
5354
if class_name.startswith("Test") or class_name.endswith("Test") or "test" in class_name.lower():
5455
potential_tests.append((test_module_name, class_name, function_name))
5556

56-
elif "test" in test_module_name or Path(filename).stem.startswith("test_"):
57+
elif "test" in test_module_name or filename_path.stem.startswith("test_"):
5758
potential_tests.append((test_module_name, None, function_name))
5859

5960
if (

0 commit comments

Comments
 (0)