Skip to content

Commit 2df0383

Browse files
committed
Added file rewritten check
1 parent 9074d9a commit 2df0383

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/codemodder/codemods/test/integration_utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ def setup_class(cls):
6969
manage_py_path = parent_dir / "manage.py"
7070
manage_py_path.touch()
7171

72-
@classmethod
73-
def teardown_class(cls):
74-
"""Ensure any re-written file is undone after integration test class"""
75-
pass
76-
7772
def _assert_run_fields(self, run, output_path):
7873
assert run["vendor"] == "pixee"
7974
assert run["tool"] == "codemodder-python"
@@ -161,6 +156,10 @@ def test_codetf_output(self, codetf_schema):
161156
"""
162157
Tests correct codetf output.
163158
"""
159+
160+
with open(self.code_path, "r", encoding="utf-8") as f: # type: ignore
161+
original_code = f.read()
162+
164163
command = [
165164
"codemodder",
166165
self.code_dir,
@@ -187,6 +186,11 @@ def test_codetf_output(self, codetf_schema):
187186
patched_codes = self._get_patched_code_for_each_change()
188187
self._check_code_after(patched_codes)
189188

189+
# check that the original file is not rewritten
190+
with open(self.code_path, "r", encoding="utf-8") as f:
191+
original_file_code = f.read()
192+
assert original_file_code == original_code
193+
190194
def apply_hunk_to_lines(self, lines, hunk):
191195
# The hunk target line numbers are 1-indexed.
192196
start_index = hunk.target_start - 1

0 commit comments

Comments
 (0)