-
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.
- Loading branch information
Showing
7 changed files
with
136 additions
and
29 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
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
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,54 @@ | ||
from pathlib import Path | ||
from typing import Iterable | ||
|
||
import pytest | ||
|
||
from rope.base.project import Project | ||
from rope.contrib.autoimport.sqlite import AutoImport | ||
|
||
|
||
@pytest.fixture | ||
def project(request, tmp_path: Path) -> Iterable[Project]: | ||
doc = request.param | ||
if doc is not None: | ||
file = tmp_path / "pyproject.toml" | ||
file.write_text(doc, encoding="utf-8") | ||
print(file, doc) | ||
project = Project(tmp_path) | ||
yield project | ||
project.close() | ||
|
||
|
||
@pytest.fixture | ||
def autoimport(project) -> Iterable[AutoImport]: | ||
autoimport = AutoImport(project, memory=True) | ||
autoimport.generate_modules_cache() | ||
yield autoimport | ||
autoimport.close() | ||
|
||
|
||
@pytest.mark.parametrize("project", ((""),), indirect=True) | ||
def test_blank(project, autoimport): | ||
assert project.prefs.dependencies is None | ||
assert autoimport.search("pytoolconfig") | ||
|
||
|
||
@pytest.mark.parametrize("project", (("[project]\n dependencies=[]"),), indirect=True) | ||
def test_empty(project, autoimport): | ||
assert len(project.prefs.dependencies) == 0 | ||
assert [] == autoimport.search("pytoolconfig") | ||
|
||
|
||
FILE = """ | ||
[project] | ||
dependencies = [ | ||
"pytoolconfig", | ||
"bogus" | ||
] | ||
""" | ||
|
||
|
||
@pytest.mark.parametrize("project", ((FILE),), indirect=True) | ||
def test_not_empty(project, autoimport): | ||
assert len(project.prefs.dependencies) == 2 | ||
assert autoimport.search("pytoolconfig") |