Skip to content

Commit a5b7557

Browse files
✅ Add needs_bash test fixture (#888)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6cc1f9a commit a5b7557

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

tests/test_completion/test_completion.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
from docs_src.commands.index import tutorial001 as mod
77

8-
from ..utils import needs_linux
8+
from ..utils import needs_bash, needs_linux
99

1010

11+
@needs_bash
1112
@needs_linux
1213
def test_show_completion():
1314
result = subprocess.run(
@@ -23,6 +24,7 @@ def test_show_completion():
2324
assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout
2425

2526

27+
@needs_bash
2628
@needs_linux
2729
def test_install_completion():
2830
bash_completion_path: Path = Path.home() / ".bashrc"

tests/utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,26 @@
22

33
import pytest
44

5+
try:
6+
import shellingham
7+
from shellingham import ShellDetectionFailure
8+
9+
shell = shellingham.detect_shell()[0]
10+
except ImportError: # pragma: no cover
11+
shellingham = None
12+
shell = None
13+
except ShellDetectionFailure: # pragma: no cover
14+
shell = None
15+
16+
517
needs_py310 = pytest.mark.skipif(
618
sys.version_info < (3, 10), reason="requires python3.10+"
719
)
820

921
needs_linux = pytest.mark.skipif(
1022
not sys.platform.startswith("linux"), reason="Test requires Linux"
1123
)
24+
25+
needs_bash = pytest.mark.skipif(
26+
not shellingham or not shell or "bash" not in shell, reason="Test requires Bash"
27+
)

0 commit comments

Comments
 (0)