Skip to content

Commit b2c7bf3

Browse files
committed
fix choices test, run zsh completion install test in a sanitary environment
1 parent c062081 commit b2c7bf3

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

tests/shellcompletion/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def test_multi_install(self):
502502

503503
if platform.system() != "Windows":
504504

505-
def test_prompt_install(self):
505+
def test_prompt_install(self, env={}):
506506
import pexpect
507507

508508
rex = re.compile
@@ -523,7 +523,7 @@ def test_prompt_install(self):
523523
self.remove()
524524
self.verify_remove()
525525

526-
install = pexpect.spawn(self.manage_script, install_command)
526+
install = pexpect.spawn(self.manage_script, install_command, env=env)
527527

528528
def wait_for_output(child) -> t.Tuple[int, t.Optional[str]]:
529529
index = child.expect(expected)
@@ -547,7 +547,7 @@ def wait_for_output(child) -> t.Tuple[int, t.Optional[str]]:
547547
self.verify_remove()
548548

549549
# test an install
550-
install = pexpect.spawn(self.manage_script, install_command)
550+
install = pexpect.spawn(self.manage_script, install_command, env=env)
551551

552552
while True:
553553
idx, _ = wait_for_output(install)

tests/shellcompletion/test_zsh.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.test import TestCase, override_settings
66
import sys
77
import os
8+
import platform
89

910
from tests.shellcompletion import (
1011
_ScriptCompleteTestCase,
@@ -61,3 +62,11 @@ def test_no_zshrc_file(self):
6162
@override_settings(TEMPLATES=[])
6263
def test_no_template_config(self):
6364
self.test_shell_complete()
65+
66+
if platform.system() != "Windows":
67+
68+
def test_prompt_install(self, env={}):
69+
zdot_dir = Path(__file__).parent / "zdotdir"
70+
zdot_dir.mkdir(exist_ok=True)
71+
super().test_prompt_install(env={"ZDOTDIR": str(zdot_dir.absolute())})
72+
shutil.rmtree(zdot_dir)

tests/test_parser_completers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,9 +2537,9 @@ def test_choices_completer(self):
25372537
set([comp[0] for comp in completions]),
25382538
)
25392539
# verify helps
2540-
if not self.shellcompletion.shell != "bash":
2540+
if self.shellcompletion.shell != "bash":
25412541
for val, help_txt in completions:
2542-
self.assertEqual(help_txt, field_choices[value])
2542+
self.assertEqual(help_txt, field_choices[type(value)(val)])
25432543

25442544
# sanity check!
25452545
self.assertEqual(n_tests, 872)

0 commit comments

Comments
 (0)