From 0c20afc3d57761572df26c9411df5cc32e35af4d Mon Sep 17 00:00:00 2001 From: clavedeluna Date: Mon, 15 Jan 2024 11:17:49 -0300 Subject: [PATCH] add test coverage --- tests/codemods/test_combine_startswith_endswith.py | 10 ++++++++++ tests/codemods/test_remove_debug_breakpoint.py | 10 ++++++++++ tests/codemods/test_subprocess_shell_false.py | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/tests/codemods/test_combine_startswith_endswith.py b/tests/codemods/test_combine_startswith_endswith.py index 19305f9d3..78e0ec728 100644 --- a/tests/codemods/test_combine_startswith_endswith.py +++ b/tests/codemods/test_combine_startswith_endswith.py @@ -38,3 +38,13 @@ def test_combine(self, tmpdir, func): def test_no_change(self, tmpdir, code): self.run_and_assert(tmpdir, code, code) assert len(self.file_context.codemod_changes) == 0 + + def test_exclude_line(self, tmpdir): + input_code = expected = f"""\ + x = "foo" + x.startswith("foo") or x.startswith("f") + """ + lines_to_exclude = [2] + self.assert_no_change_line_excluded( + tmpdir, input_code, expected, lines_to_exclude + ) diff --git a/tests/codemods/test_remove_debug_breakpoint.py b/tests/codemods/test_remove_debug_breakpoint.py index 27e10b834..996ebabf3 100644 --- a/tests/codemods/test_remove_debug_breakpoint.py +++ b/tests/codemods/test_remove_debug_breakpoint.py @@ -85,3 +85,13 @@ def something(): """ self.run_and_assert(tmpdir, input_code, expected) assert len(self.file_context.codemod_changes) == 1 + + def test_exclude_line(self, tmpdir): + input_code = expected = f"""\ + x = "foo" + breakpoint() + """ + lines_to_exclude = [2] + self.assert_no_change_line_excluded( + tmpdir, input_code, expected, lines_to_exclude + ) diff --git a/tests/codemods/test_subprocess_shell_false.py b/tests/codemods/test_subprocess_shell_false.py index b19c95134..4b178a481 100644 --- a/tests/codemods/test_subprocess_shell_false.py +++ b/tests/codemods/test_subprocess_shell_false.py @@ -56,3 +56,13 @@ def test_shell_False(self, tmpdir, func): """ self.run_and_assert(tmpdir, input_code, input_code) assert len(self.file_context.codemod_changes) == 0 + + def test_exclude_line(self, tmpdir): + input_code = expected = """\ + import subprocess + subprocess.run(args, shell=True) + """ + lines_to_exclude = [2] + self.assert_no_change_line_excluded( + tmpdir, input_code, expected, lines_to_exclude + )