-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #648 from bagel897/autoimport-fix-bug
Remove __init__ from import statement when using sqlite autoimport
- Loading branch information
Showing
3 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Special cases, easier to express in pytest | ||
from contextlib import closing | ||
from textwrap import dedent | ||
|
||
import pytest | ||
|
||
from rope.base.project import Project | ||
from rope.base.resources import File, Folder | ||
from rope.contrib.autoimport.sqlite import AutoImport | ||
|
||
|
||
@pytest.fixture | ||
def autoimport(project: Project): | ||
with closing(AutoImport(project)) as ai: | ||
yield ai | ||
|
||
|
||
def test_init_py( | ||
autoimport: AutoImport, | ||
project: Project, | ||
pkg1: Folder, | ||
mod1: File, | ||
): | ||
mod1_init = pkg1.get_child("__init__.py") | ||
mod1_init.write(dedent("""\ | ||
def foo(): | ||
pass | ||
""")) | ||
mod1.write(dedent("""\ | ||
foo | ||
""")) | ||
autoimport.generate_cache([mod1_init]) | ||
results = autoimport.search("foo", True) | ||
assert [("from pkg1 import foo", "foo")] == results |