-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
5 changed files
with
72 additions
and
10 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,2 @@ | ||
pytest | ||
pytest-plus |
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,52 @@ | ||
import os | ||
from subprocess import run | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"shell,expected", | ||
( | ||
pytest.param("zsh", "_mk_completion()", id="zsh"), | ||
pytest.param("bash", "_mk_completion()", id="bash"), | ||
), | ||
) | ||
def test_show_completion_script(shell, expected) -> None: | ||
"""Tests completion script generation.""" | ||
env = os.environ.copy() | ||
env["SHELL"] = f"/bin/{shell}" | ||
result = run( | ||
["mk", "--show-completion"], universal_newlines=True, capture_output=True, env=env | ||
) | ||
assert result.returncode == 0, result | ||
# very important as we could easily break it by sending data to stdout | ||
assert expected in result.stdout | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"shell,expected", | ||
( | ||
pytest.param("zsh", "_arguments", id="zsh"), | ||
pytest.param("bash", "detect\n", id="bash"), | ||
), | ||
) | ||
def test_show_completion_data(shell, expected) -> None: | ||
"""Tests completion hints.""" | ||
env = os.environ.copy() | ||
env["_MK_COMPLETE"] = f"complete_{shell}" | ||
env["_TYPER_COMPLETE_ARGS"] = "" | ||
result = run( | ||
["mk", "--show-completion"], universal_newlines=True, capture_output=True, env=env | ||
) | ||
# Apparently test return an unexpected 1 even if completion seems to be | ||
# working, disabling return code testing until we know why. | ||
# assert result.returncode == 0, result | ||
# very important as we could easily break it by sending data to stdout | ||
assert result.stdout.startswith(expected) | ||
|
||
|
||
def test_help() -> None: | ||
"""Tests display of help.""" | ||
result = run(["mk", "--help"], universal_newlines=True, capture_output=True) | ||
assert result.returncode == 0, result | ||
# very important as we could easily break it by sending data to stdout | ||
assert result.stdout.startswith("Usage: mk") |
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