Skip to content

Commit 458367e

Browse files
gh-154419: Find the fish shell in test_venv (GH-154420)
shutil.which('fish') can find the unrelated "Go Fish" game, which is shipped on several BSD systems. Search PATH for an executable which behaves like the fish shell instead. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent b0c945a commit 458367e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

Lib/test/test_venv.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,16 @@ def test_fish_activate_shadowed_builtins(self):
783783
shadows one of those builtins (a common pattern for `.`-style directory
784784
navigators) must not hijack the prompt or break status restoration.
785785
"""
786-
fish = shutil.which('fish')
787-
if fish is None:
786+
# Some systems have an unrelated "fish" game (see fish(6)), which
787+
# can precede the fish shell in PATH.
788+
for dirname in None, *os.get_exec_path():
789+
fish = shutil.which('fish', path=dirname)
790+
if fish is not None and subprocess.run(
791+
[fish, '-c', 'echo $FISH_VERSION'],
792+
stdin=subprocess.DEVNULL,
793+
capture_output=True).stdout.strip():
794+
break
795+
else:
788796
self.skipTest('fish required for this test')
789797
rmtree(self.env_dir)
790798
builder = venv.EnvBuilder(clear=True)

0 commit comments

Comments
 (0)