Skip to content

Commit

Permalink
✅ Add needs_bash test fixture (#888)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
svlandeg and pre-commit-ci[bot] authored Aug 24, 2024
1 parent 6cc1f9a commit a5b7557
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/test_completion/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"
Expand Down
16 changes: 16 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@

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+"
)

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"
)

0 comments on commit a5b7557

Please sign in to comment.