Skip to content

Commit

Permalink
Added test for exceptions in RemoveUnusedImports
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecsilva committed Oct 26, 2023
1 parent 39edc0f commit 73f5b4a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/codemods/test_remove_unused_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,15 @@ def test_ignore_init_files(self, tmpdir):
tmp_file_path = Path(tmpdir / "__init__.py")
self.run_and_assert_filepath(tmpdir, tmp_file_path, before, before)
assert len(self.file_context.codemod_changes) == 0

def test_no_pyling_pragma_in_comment_trailing(self, tmpdir):
before = "import a # bogus: no-pragma"
after = ""
self.run_and_assert(tmpdir, before, after)
assert len(self.file_context.codemod_changes) == 1

def test_no_pyling_pragma_in_comment_before(self, tmpdir):
before = "#header\nprint('hello')\n# bogus: no-pragma\nimport a "
after = "#header\nprint('hello')"
self.run_and_assert(tmpdir, before, after)
assert len(self.file_context.codemod_changes) == 1

0 comments on commit 73f5b4a

Please sign in to comment.