@@ -152,20 +152,8 @@ def test_ignored_certain_directories(self, pytester: Pytester) -> None:
152152 assert "test_notfound" not in s
153153 assert "test_found" in s
154154
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" )
169157 testfile = ensure_file (pytester .path / "virtual" / "test_invenv.py" )
170158 testfile .write_text ("def test_hello(): pass" , encoding = "utf-8" )
171159
@@ -179,23 +167,11 @@ def test_ignored_virtualenvs(self, pytester: Pytester, fname: str) -> None:
179167 result = pytester .runpytest ("virtual" )
180168 assert "test_invenv" in result .stdout .str ()
181169
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- )
193170 def test_ignored_virtualenvs_norecursedirs_precedence (
194- self , pytester : Pytester , fname : str
171+ self , pytester : Pytester
195172 ) -> None :
196- bindir = "Scripts" if sys .platform .startswith ("win" ) else "bin"
197173 # norecursedirs takes priority
198- ensure_file (pytester .path / ".virtual" / bindir / fname )
174+ ensure_file (pytester .path / ".virtual" / "pyvenv.cfg" )
199175 testfile = ensure_file (pytester .path / ".virtual" / "test_invenv.py" )
200176 testfile .write_text ("def test_hello(): pass" , encoding = "utf-8" )
201177 result = pytester .runpytest ("--collect-in-virtualenv" )
@@ -204,27 +180,13 @@ def test_ignored_virtualenvs_norecursedirs_precedence(
204180 result = pytester .runpytest ("--collect-in-virtualenv" , ".virtual" )
205181 assert "test_invenv" in result .stdout .str ()
206182
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 :
219184 """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
222186 base_path = pytester .mkdir ("venv" )
223187 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 ()
228190 assert _in_venv (base_path ) is True
229191
230192 def test_custom_norecursedirs (self , pytester : Pytester ) -> None :
0 commit comments