Skip to content

Commit 41d211c

Browse files
authored
testing: use a tighter check if bash is available (#7520)
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 41d211c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

testing/test_parseopt.py

Lines changed: 14 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,19 @@ 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"],
294+
stdout=subprocess.PIPE,
295+
stderr=subprocess.PIPE,
296+
universal_newlines=True,
297+
).stdout
298+
except OSError:
299+
pytest.skip("bash is not available")
300+
if "GNU bash" not in bash_version:
301+
# See #7518.
302+
pytest.skip("not a real bash")
303+
293304
script = str(testdir.tmpdir.join("test_argcomplete"))
294305

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

0 commit comments

Comments
 (0)