@@ -51,13 +51,14 @@ def test_venv_not_installed_windows():
51
51
52
52
53
53
@pytest .mark .parametrize ("env_exists" , ["hasEnv" , "noEnv" ])
54
- @pytest .mark .parametrize ("git_ignore" , ["useGitIgnore" , "skipGitIgnore" ])
54
+ @pytest .mark .parametrize ("git_ignore" , ["useGitIgnore" , "skipGitIgnore" , "gitIgnoreExists" ])
55
55
@pytest .mark .parametrize ("install" , ["requirements" , "toml" , "skipInstall" ])
56
56
def test_create_env (env_exists , git_ignore , install ):
57
57
importlib .reload (create_venv )
58
58
create_venv .is_installed = lambda _x : True
59
59
create_venv .venv_exists = lambda _n : env_exists == "hasEnv"
60
60
create_venv .upgrade_pip = lambda _x : None
61
+ create_venv .is_file = lambda _x : git_ignore == "gitIgnoreExists"
61
62
62
63
install_packages_called = False
63
64
@@ -84,9 +85,19 @@ def run_process(args, error_message):
84
85
def add_gitignore (_name ):
85
86
nonlocal add_gitignore_called
86
87
add_gitignore_called = True
88
+ if not create_venv .is_file (_name ):
89
+ create_venv .create_gitignore (_name )
87
90
88
91
create_venv .add_gitignore = add_gitignore
89
92
93
+ create_gitignore_called = False
94
+
95
+ def create_gitignore (_p ):
96
+ nonlocal create_gitignore_called
97
+ create_gitignore_called = True
98
+
99
+ create_venv .create_gitignore = create_gitignore
100
+
90
101
args = []
91
102
if git_ignore == "useGitIgnore" :
92
103
args += ["--git-ignore" ]
@@ -104,6 +115,8 @@ def add_gitignore(_name):
104
115
# add_gitignore is called when new venv is created and git_ignore is True
105
116
assert add_gitignore_called == ((env_exists == "noEnv" ) and (git_ignore == "useGitIgnore" ))
106
117
118
+ assert create_gitignore_called == (add_gitignore_called and (git_ignore != "gitIgnoreExists" ))
119
+
107
120
108
121
@pytest .mark .parametrize ("install_type" , ["requirements" , "pyproject" , "both" ])
109
122
def test_install_packages (install_type ):
0 commit comments