This repository has been archived by the owner on Jan 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
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 #247 from dephell/fuzzy-commands
Fuzzy command search
- Loading branch information
Showing
3 changed files
with
83 additions
and
17 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 |
---|---|---|
@@ -1,12 +1,38 @@ | ||
# built-in | ||
from pathlib import Path | ||
|
||
# external | ||
import pytest | ||
|
||
# project | ||
from dephell.cli import main | ||
from dephell.cli import get_command_name_and_size, main | ||
|
||
|
||
@pytest.mark.parametrize('given, expected', [ | ||
('venv shell', 'venv shell'), | ||
('shell venv', 'venv shell'), | ||
('import', 'vendor import'), | ||
('vnv shell', 'venv shell'), | ||
('vnev shell', 'venv shell'), | ||
('venv shll', 'venv shell'), | ||
('venv shel', 'venv shell'), | ||
('venv sl', None), | ||
]) | ||
def test_get_command_name_and_size(given, expected): | ||
result = get_command_name_and_size(argv=given.split()) | ||
if expected is None: | ||
assert result is None | ||
else: | ||
assert result is not None | ||
assert result[0] == expected | ||
|
||
|
||
def test_main(tmpdir): | ||
config = tmpdir.join('pyproject.toml') | ||
result = main(['generate config', '--config', str(config), '--project', str(tmpdir)]) | ||
def test_main(temp_path: Path): | ||
config = temp_path / 'pyproject.toml' | ||
result = main(['generate config', '--config', str(config), '--project', str(temp_path)]) | ||
assert result == 0 | ||
|
||
assert config.check(file=1, exists=1) | ||
content = config.read() | ||
assert config.exists() | ||
assert config.is_file() | ||
content = config.read_text() | ||
assert '[tool.dephell.example]' in content |