@@ -152,20 +152,8 @@ def test_ignored_certain_directories(self, pytester: Pytester) -> None:
152
152
assert "test_notfound" not in s
153
153
assert "test_found" in s
154
154
155
- @pytest .mark .parametrize (
156
- "fname" ,
157
- (
158
- "activate" ,
159
- "activate.csh" ,
160
- "activate.fish" ,
161
- "Activate" ,
162
- "Activate.bat" ,
163
- "Activate.ps1" ,
164
- ),
165
- )
166
- def test_ignored_virtualenvs (self , pytester : Pytester , fname : str ) -> None :
167
- bindir = "Scripts" if sys .platform .startswith ("win" ) else "bin"
168
- ensure_file (pytester .path / "virtual" / bindir / fname )
155
+ def test_ignored_virtualenvs (self , pytester : Pytester ) -> None :
156
+ ensure_file (pytester .path / "virtual" / "pyvenv.cfg" )
169
157
testfile = ensure_file (pytester .path / "virtual" / "test_invenv.py" )
170
158
testfile .write_text ("def test_hello(): pass" , encoding = "utf-8" )
171
159
@@ -179,23 +167,11 @@ def test_ignored_virtualenvs(self, pytester: Pytester, fname: str) -> None:
179
167
result = pytester .runpytest ("virtual" )
180
168
assert "test_invenv" in result .stdout .str ()
181
169
182
- @pytest .mark .parametrize (
183
- "fname" ,
184
- (
185
- "activate" ,
186
- "activate.csh" ,
187
- "activate.fish" ,
188
- "Activate" ,
189
- "Activate.bat" ,
190
- "Activate.ps1" ,
191
- ),
192
- )
193
170
def test_ignored_virtualenvs_norecursedirs_precedence (
194
- self , pytester : Pytester , fname : str
171
+ self , pytester : Pytester
195
172
) -> None :
196
- bindir = "Scripts" if sys .platform .startswith ("win" ) else "bin"
197
173
# norecursedirs takes priority
198
- ensure_file (pytester .path / ".virtual" / bindir / fname )
174
+ ensure_file (pytester .path / ".virtual" / "pyvenv.cfg" )
199
175
testfile = ensure_file (pytester .path / ".virtual" / "test_invenv.py" )
200
176
testfile .write_text ("def test_hello(): pass" , encoding = "utf-8" )
201
177
result = pytester .runpytest ("--collect-in-virtualenv" )
@@ -204,27 +180,13 @@ def test_ignored_virtualenvs_norecursedirs_precedence(
204
180
result = pytester .runpytest ("--collect-in-virtualenv" , ".virtual" )
205
181
assert "test_invenv" in result .stdout .str ()
206
182
207
- @pytest .mark .parametrize (
208
- "fname" ,
209
- (
210
- "activate" ,
211
- "activate.csh" ,
212
- "activate.fish" ,
213
- "Activate" ,
214
- "Activate.bat" ,
215
- "Activate.ps1" ,
216
- ),
217
- )
218
- def test__in_venv (self , pytester : Pytester , fname : str ) -> None :
183
+ def test__in_venv (self , pytester : Pytester ) -> None :
219
184
"""Directly test the virtual env detection function"""
220
- bindir = "Scripts" if sys .platform .startswith ("win" ) else "bin"
221
- # no bin/activate, not a virtualenv
185
+ # no pyvenv.cfg, not a virtualenv
222
186
base_path = pytester .mkdir ("venv" )
223
187
assert _in_venv (base_path ) is False
224
- # with bin/activate, totally a virtualenv
225
- bin_path = base_path .joinpath (bindir )
226
- bin_path .mkdir ()
227
- bin_path .joinpath (fname ).touch ()
188
+ # with pyvenv.cfg, totally a virtualenv
189
+ base_path .joinpath ("pyvenv.cfg" ).touch ()
228
190
assert _in_venv (base_path ) is True
229
191
230
192
def test_custom_norecursedirs (self , pytester : Pytester ) -> None :
0 commit comments