1
1
import shutil
2
2
from pathlib import Path
3
+ import typing as t
3
4
4
5
import pytest
5
6
from django .test import TestCase , override_settings
@@ -25,15 +26,21 @@ class ZshTests(_ScriptCompleteTestCase, TestCase):
25
26
f"DJANGO_SETTINGS_MODULE=tests.settings.completion" ,
26
27
]
27
28
28
- def verify_install (self , script = None ):
29
+ def verify_install (self , script = None , directory : t . Optional [ Path ] = None ):
29
30
if not script :
30
31
script = self .manage_script
31
- self .assertTrue ((self . directory / f"_{ script } " ).exists ())
32
+ self .assertTrue ((directory / f"_{ script } " ).exists ())
32
33
33
- def verify_remove (self , script = None ):
34
+ def verify_remove (self , script = None , directory : t .Optional [Path ] = None ):
35
+ directory = directory or self .directory
34
36
if not script :
35
37
script = self .manage_script
36
- self .assertFalse ((self .directory / f"_{ script } " ).exists ())
38
+ try :
39
+ self .assertFalse ((directory / f"_{ script } " ).exists ())
40
+ except AssertionError :
41
+ import ipdb
42
+
43
+ ipdb .set_trace ()
37
44
38
45
39
46
@pytest .mark .skipif (shutil .which ("zsh" ) is None , reason = "Z-Shell not available" )
@@ -65,8 +72,14 @@ def test_no_template_config(self):
65
72
66
73
if platform .system () != "Windows" :
67
74
68
- def test_prompt_install (self , env = {}):
75
+ def test_prompt_install (self , env = {}, directory = None ):
69
76
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 )
77
+ try :
78
+ zdot_dir .mkdir (exist_ok = True )
79
+ super ().test_prompt_install (
80
+ env = {"ZDOTDIR" : str (zdot_dir .absolute ())},
81
+ directory = zdot_dir / ".zfunc" ,
82
+ )
83
+ finally :
84
+ if zdot_dir .exists ():
85
+ shutil .rmtree (zdot_dir )
0 commit comments