diff --git a/tests/test_completion/test_completion.py b/tests/test_completion/test_completion.py index 36581aba09..4e1586e51d 100644 --- a/tests/test_completion/test_completion.py +++ b/tests/test_completion/test_completion.py @@ -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 @@ -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 = "" diff --git a/tests/test_completion/test_completion_install.py b/tests/test_completion/test_completion_install.py index 7c9054e250..873c1416e9 100644 --- a/tests/test_completion/test_completion_install.py +++ b/tests/test_completion/test_completion_install.py @@ -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"], @@ -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 = "" @@ -67,6 +71,7 @@ def test_completion_install_bash(): ) +@requires_completion_permission def test_completion_install_zsh(): completion_path: Path = Path.home() / ".zshrc" text = "" @@ -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 = ( @@ -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" diff --git a/tests/test_others.py b/tests/test_others.py index a577369b16..1078e63d1f 100644 --- a/tests/test_others.py +++ b/tests/test_others.py @@ -15,6 +15,8 @@ from typer.models import ParameterInfo, TyperInfo from typer.testing import CliRunner +from .utils import requires_completion_permission + runner = CliRunner() @@ -74,6 +76,7 @@ def convert( ParameterInfo(click_type=CustomClickParser()) +@requires_completion_permission def test_install_invalid_shell(): app = typer.Typer()