Skip to content

Commit

Permalink
Add @requires_completion_permission marker to all tests running --ins…
Browse files Browse the repository at this point in the history
…tall-completion
  • Loading branch information
svlandeg committed Sep 17, 2024
1 parent a70ebff commit 3980ed3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/test_completion/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from docs_src.commands.index import tutorial001 as mod

from ..utils import needs_bash, needs_linux
from ..utils import needs_bash, needs_linux, requires_completion_permission


@needs_bash
Expand All @@ -26,6 +26,7 @@ def test_show_completion():

@needs_bash
@needs_linux
@requires_completion_permission
def test_install_completion():
bash_completion_path: Path = Path.home() / ".bashrc"
text = ""
Expand Down
7 changes: 7 additions & 0 deletions tests/test_completion/test_completion_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

from docs_src.commands.index import tutorial001 as mod

from ..utils import requires_completion_permission

runner = CliRunner()
app = typer.Typer()
app.command()(mod.main)


@requires_completion_permission
def test_completion_install_no_shell():
result = subprocess.run(
[sys.executable, "-m", "coverage", "run", mod.__file__, "--install-completion"],
Expand All @@ -28,6 +31,7 @@ def test_completion_install_no_shell():
assert "Option '--install-completion' requires an argument" in result.stderr


@requires_completion_permission
def test_completion_install_bash():
bash_completion_path: Path = Path.home() / ".bashrc"
text = ""
Expand Down Expand Up @@ -67,6 +71,7 @@ def test_completion_install_bash():
)


@requires_completion_permission
def test_completion_install_zsh():
completion_path: Path = Path.home() / ".zshrc"
text = ""
Expand Down Expand Up @@ -104,6 +109,7 @@ def test_completion_install_zsh():
assert "compdef _tutorial001py_completion tutorial001.py" in install_content


@requires_completion_permission
def test_completion_install_fish():
script_path = Path(mod.__file__)
completion_path: Path = (
Expand Down Expand Up @@ -133,6 +139,7 @@ def test_completion_install_fish():
assert "Completion will take effect once you restart the terminal" in result.stdout


@requires_completion_permission
def test_completion_install_powershell():
completion_path: Path = (
Path.home() / ".config/powershell/Microsoft.PowerShell_profile.ps1"
Expand Down
3 changes: 3 additions & 0 deletions tests/test_others.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from typer.models import ParameterInfo, TyperInfo
from typer.testing import CliRunner

from .utils import requires_completion_permission

runner = CliRunner()


Expand Down Expand Up @@ -74,6 +76,7 @@ def convert(
ParameterInfo(click_type=CustomClickParser())


@requires_completion_permission
def test_install_invalid_shell():
app = typer.Typer()

Expand Down

0 comments on commit 3980ed3

Please sign in to comment.