Skip to content

Commit b7514e1

Browse files
authored
add detector name and update test utils (#488)
add file ext to tests
1 parent f024a91 commit b7514e1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/codemodder/codemods/test/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
class BaseCodemodTest:
1515
codemod: ClassVar = NotImplemented
1616

17+
@property
18+
def file_extension(self) -> str:
19+
return "py"
20+
1721
def setup_method(self):
1822
if isinstance(self.codemod, type):
1923
self.codemod = self.codemod()
@@ -30,7 +34,9 @@ def run_and_assert(
3034
lines_to_exclude: list[int] | None = None,
3135
):
3236
root = root or tmpdir
33-
tmp_file_path = files[0] if files else Path(tmpdir) / "code.py"
37+
tmp_file_path = (
38+
files[0] if files else Path(tmpdir) / f"code.{self.file_extension}"
39+
)
3440
tmp_file_path.write_text(dedent(input_code))
3541

3642
files_to_check = files or [tmp_file_path]
@@ -142,7 +148,9 @@ def run_and_assert(
142148
results: str = "",
143149
):
144150
root = root or tmpdir
145-
tmp_file_path = files[0] if files else Path(tmpdir) / "code.py"
151+
tmp_file_path = (
152+
files[0] if files else Path(tmpdir) / f"code.{self.file_extension}"
153+
)
146154
tmp_file_path.write_text(dedent(input_code))
147155

148156
tmp_results_file_path = Path(tmpdir) / "sast_results"

0 commit comments

Comments
 (0)