Skip to content

Commit

Permalink
add test for existing common_statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasha10 committed Nov 21, 2021
1 parent b0969ab commit 4bd3bfd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/unit/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,3 +870,27 @@ def test_file_that_only_has_unused_imports() -> None:
result = fix_code(source)

assert result == "\n"


def test_file_with_common_statement() -> None:
"""
Given: Code with a commonly-used object.
When: Fix code is run.
Then: The appropriate import statement from the common_statements dict is added.
"""
source = dedent(
"""\
BeautifulSoup
"""
)
desired_source = dedent(
"""\
from bs4 import BeautifulSoup
BeautifulSoup
"""
)

result = fix_code(source)

assert result == desired_source

0 comments on commit 4bd3bfd

Please sign in to comment.