33
44import os
55from pathlib import Path
6+ from pathlib import PurePath
67import pprint
78import shutil
89import sys
@@ -152,8 +153,17 @@ def test_ignored_certain_directories(self, pytester: Pytester) -> None:
152153 assert "test_notfound" not in s
153154 assert "test_found" in s
154155
155- def test_ignored_virtualenvs (self , pytester : Pytester ) -> None :
156- ensure_file (pytester .path / "virtual" / "pyvenv.cfg" )
156+ known_environment_types = pytest .mark .parametrize (
157+ "env_path" ,
158+ [
159+ pytest .param (PurePath ("pyvenv.cfg" ), id = "venv" ),
160+ pytest .param (PurePath ("conda-meta" , "history" ), id = "conda" ),
161+ ],
162+ )
163+
164+ @known_environment_types
165+ def test_ignored_virtualenvs (self , pytester : Pytester , env_path : PurePath ) -> None :
166+ ensure_file (pytester .path / "virtual" / env_path )
157167 testfile = ensure_file (pytester .path / "virtual" / "test_invenv.py" )
158168 testfile .write_text ("def test_hello(): pass" , encoding = "utf-8" )
159169
@@ -167,11 +177,12 @@ def test_ignored_virtualenvs(self, pytester: Pytester) -> None:
167177 result = pytester .runpytest ("virtual" )
168178 assert "test_invenv" in result .stdout .str ()
169179
180+ @known_environment_types
170181 def test_ignored_virtualenvs_norecursedirs_precedence (
171- self , pytester : Pytester
182+ self , pytester : Pytester , env_path
172183 ) -> None :
173184 # norecursedirs takes priority
174- ensure_file (pytester .path / ".virtual" / "pyvenv.cfg" )
185+ ensure_file (pytester .path / ".virtual" / env_path )
175186 testfile = ensure_file (pytester .path / ".virtual" / "test_invenv.py" )
176187 testfile .write_text ("def test_hello(): pass" , encoding = "utf-8" )
177188 result = pytester .runpytest ("--collect-in-virtualenv" )
@@ -180,13 +191,14 @@ def test_ignored_virtualenvs_norecursedirs_precedence(
180191 result = pytester .runpytest ("--collect-in-virtualenv" , ".virtual" )
181192 assert "test_invenv" in result .stdout .str ()
182193
183- def test__in_venv (self , pytester : Pytester ) -> None :
194+ @known_environment_types
195+ def test__in_venv (self , pytester : Pytester , env_path : PurePath ) -> None :
184196 """Directly test the virtual env detection function"""
185- # no pyvenv.cfg , not a virtualenv
197+ # no env path , not a env
186198 base_path = pytester .mkdir ("venv" )
187199 assert _in_venv (base_path ) is False
188- # with pyvenv.cfg , totally a virtualenv
189- base_path .joinpath ("pyvenv.cfg" ). touch ( )
200+ # with env path , totally a env
201+ ensure_file ( base_path .joinpath (env_path ) )
190202 assert _in_venv (base_path ) is True
191203
192204 def test_custom_norecursedirs (self , pytester : Pytester ) -> None :
0 commit comments