Skip to content

Commit 900647f

Browse files
committed
testing: use a tighter check if bash is available
This fixes CI on Windows since GitHub Actions started installing WSL on their images which apparently installs some wrapper `bash` which does not run actual bash.
1 parent 07ed197 commit 900647f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

testing/test_parseopt.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
import os
33
import shlex
4-
import shutil
4+
import subprocess
55
import sys
66

77
import py
@@ -288,8 +288,16 @@ def test_multiple_metavar_help(self, parser: parseopt.Parser) -> None:
288288

289289

290290
def test_argcomplete(testdir, monkeypatch) -> None:
291-
if not shutil.which("bash"):
292-
pytest.skip("bash not available")
291+
try:
292+
bash_version = subprocess.run(
293+
["bash", "--version"], capture_output=True, universal_newlines=True
294+
).stdout
295+
except Exception:
296+
pytest.skip("bash is not available")
297+
if "GNU bash" not in bash_version:
298+
# See #7518.
299+
pytest.skip("not a real bash")
300+
293301
script = str(testdir.tmpdir.join("test_argcomplete"))
294302

295303
with open(str(script), "w") as fp:

0 commit comments

Comments
 (0)