Skip to content

Commit 08b690f

Browse files
committed
tests: update test_fish.py
Add `test_fish_path` to verify that the PATH is reverted to the original PATH after virtualenv deactivation. This verification confirms that the `_OLD_VIRTUAL_PATH` was correctly set in fish during the activation of the virtualenv.
1 parent 55caf36 commit 08b690f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/unit/activation/test_fish.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,33 @@ def print_prompt(self):
2121
return "fish_prompt"
2222

2323
activation_tester(Fish)
24+
25+
26+
@pytest.mark.skipif(IS_WIN, reason="we have not setup fish in CI yet")
27+
def test_fish_path(activation_tester_class, activation_tester, monkeypatch, tmp_path):
28+
monkeypatch.setenv("HOME", str(tmp_path))
29+
fish_conf_dir = tmp_path / ".config" / "fish"
30+
fish_conf_dir.mkdir(parents=True)
31+
(fish_conf_dir / "config.fish").write_text("", encoding="utf-8")
32+
33+
class Fish(activation_tester_class):
34+
def __init__(self, session) -> None:
35+
super().__init__(FishActivator, session, "fish", "activate.fish", "fish")
36+
37+
def print_prompt(self):
38+
return "fish_prompt"
39+
40+
def _get_test_lines(self, activate_script):
41+
return [
42+
self.print_os_env_var("PATH"),
43+
self.activate_call(activate_script),
44+
self.print_os_env_var("PATH"),
45+
self.deactivate,
46+
self.print_os_env_var("PATH"),
47+
]
48+
49+
def assert_output(self, out, raw, _):
50+
assert out[0] == out[2], raw
51+
assert out[0] != out[1], raw
52+
53+
activation_tester(Fish)

0 commit comments

Comments
 (0)