@@ -1979,8 +1979,76 @@ def test_create_python_site_packages_path(tmp_home, tmp_root_prefix):
19791979@pytest .mark .parametrize ("shared_pkgs_dirs" , [True ], indirect = True )
19801980@pytest .mark .parametrize ("env_file" , env_files )
19811981def test_requires_pip_install (tmp_home , tmp_root_prefix , env_file ):
1982- cmd = ["-p" , "myenv" , "-f" , env_file ]
1983- helpers .create (* cmd )
1982+ umamba = helpers .get_umamba ()
1983+
1984+ # Test 1: By default, pip output should be visible (no --quiet flag)
1985+ env_prefix_1 = tmp_root_prefix / "envs" / "myenv1"
1986+ cmd1 = [
1987+ umamba ,
1988+ "create" ,
1989+ "-p" ,
1990+ str (env_prefix_1 ),
1991+ "-f" ,
1992+ str (env_file ),
1993+ "-y" ,
1994+ "--no-rc" ,
1995+ ] + helpers .channel
1996+ result1 = subprocess .run (cmd1 , capture_output = True , text = True , check = True )
1997+ # pip typically outputs to stderr, so check for common pip output patterns
1998+ # Look for pip installation messages like "Collecting", "Installing", "Successfully installed"
1999+ pip_output_present = (
2000+ "Collecting" in result1 .stderr
2001+ or "Installing" in result1 .stderr
2002+ or "Successfully installed" in result1 .stderr
2003+ or "Downloading" in result1 .stderr
2004+ )
2005+ assert pip_output_present , "pip output should be visible by default (no --quiet flag)"
2006+
2007+ # Test 2: With --json, pip output should be suppressed (--quiet flag used)
2008+ env_prefix_2 = tmp_root_prefix / "envs" / "myenv2"
2009+ cmd2 = [
2010+ umamba ,
2011+ "create" ,
2012+ "-p" ,
2013+ str (env_prefix_2 ),
2014+ "-f" ,
2015+ str (env_file ),
2016+ "-y" ,
2017+ "--no-rc" ,
2018+ "--json" ,
2019+ ] + helpers .channel
2020+ result2 = subprocess .run (cmd2 , capture_output = True , text = True , check = True )
2021+ # With --quiet, pip should not output installation messages
2022+ pip_output_suppressed_json = not (
2023+ "Collecting" in result2 .stderr
2024+ or "Installing" in result2 .stderr
2025+ or "Successfully installed" in result2 .stderr
2026+ or "Downloading" in result2 .stderr
2027+ )
2028+ assert pip_output_suppressed_json , "pip output should be suppressed when --json is used"
2029+
2030+ # Test 3: With --quiet, pip output should be suppressed (--quiet flag used)
2031+ env_prefix_3 = tmp_root_prefix / "envs" / "myenv3"
2032+ cmd3 = [
2033+ umamba ,
2034+ "create" ,
2035+ "-p" ,
2036+ str (env_prefix_3 ),
2037+ "-f" ,
2038+ str (env_file ),
2039+ "-y" ,
2040+ "--no-rc" ,
2041+ "--quiet" ,
2042+ ] + helpers .channel
2043+ result3 = subprocess .run (cmd3 , capture_output = True , text = True , check = True )
2044+ # With --quiet, pip should not output installation messages
2045+ pip_output_suppressed_quiet = not (
2046+ "Collecting" in result3 .stderr
2047+ or "Installing" in result3 .stderr
2048+ or "Successfully installed" in result3 .stderr
2049+ or "Downloading" in result3 .stderr
2050+ )
2051+ assert pip_output_suppressed_quiet , "pip output should be suppressed when --quiet is used"
19842052
19852053
19862054@pytest .mark .parametrize ("shared_pkgs_dirs" , [True ], indirect = True )
0 commit comments