diff --git a/tests/test_completion/test_completion.py b/tests/test_completion/test_completion.py index 703373b226..36581aba09 100644 --- a/tests/test_completion/test_completion.py +++ b/tests/test_completion/test_completion.py @@ -5,9 +5,10 @@ from docs_src.commands.index import tutorial001 as mod -from ..utils import needs_linux +from ..utils import needs_bash, needs_linux +@needs_bash @needs_linux def test_show_completion(): result = subprocess.run( @@ -23,6 +24,7 @@ def test_show_completion(): assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout +@needs_bash @needs_linux def test_install_completion(): bash_completion_path: Path = Path.home() / ".bashrc" diff --git a/tests/utils.py b/tests/utils.py index 9b503ff799..8f51332ee2 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -2,6 +2,18 @@ import pytest +try: + import shellingham + from shellingham import ShellDetectionFailure + + shell = shellingham.detect_shell()[0] +except ImportError: # pragma: no cover + shellingham = None + shell = None +except ShellDetectionFailure: # pragma: no cover + shell = None + + needs_py310 = pytest.mark.skipif( sys.version_info < (3, 10), reason="requires python3.10+" ) @@ -9,3 +21,7 @@ needs_linux = pytest.mark.skipif( not sys.platform.startswith("linux"), reason="Test requires Linux" ) + +needs_bash = pytest.mark.skipif( + not shellingham or not shell or "bash" not in shell, reason="Test requires Bash" +)