@@ -809,16 +809,23 @@ def platform_conda_exe(request, tmp_path) -> tuple[str, Path]:
809809 return platform , conda_exe
810810
811811
812- def test_example_customize_controls (tmp_path , request ):
812+ @pytest .mark .parametrize (
813+ "installer_type" , installer_types_for_example (_example_path ("customize_controls" ))
814+ )
815+ def test_example_customize_controls (tmp_path , request , installer_type ):
813816 input_path = _example_path ("customize_controls" )
814- for installer , install_dir in create_installer (input_path , tmp_path ):
815- _run_installer (input_path , installer , install_dir , request = request )
817+ installer , install_dir = create_single_installer (input_path , tmp_path , installer_type )
818+ _run_installer (input_path , installer , install_dir , request = request )
816819
817820
818- def test_example_customized_welcome_conclusion (tmp_path , request ):
821+ @pytest .mark .parametrize (
822+ "installer_type" ,
823+ installer_types_for_example (_example_path ("customized_welcome_conclusion" )),
824+ )
825+ def test_example_customized_welcome_conclusion (tmp_path , request , installer_type ):
819826 input_path = _example_path ("customized_welcome_conclusion" )
820- for installer , install_dir in create_installer (input_path , tmp_path ):
821- _run_installer (input_path , installer , install_dir , request = request )
827+ installer , install_dir = create_single_installer (input_path , tmp_path , installer_type )
828+ _run_installer (input_path , installer , install_dir , request = request )
822829
823830
824831@pytest .mark .parametrize ("extra_pages" , ("str" , "list" ))
@@ -849,42 +856,50 @@ def test_example_extra_envs(tmp_path, request):
849856 _run_uninstaller_exe (install_dir = install_dir )
850857
851858
852- def test_example_extra_files (tmp_path , request ):
859+ @pytest .mark .parametrize (
860+ "installer_type" , installer_types_for_example (_example_path ("extra_files" ))
861+ )
862+ def test_example_extra_files (tmp_path , request , installer_type ):
853863 input_path = _example_path ("extra_files" )
854- for installer , install_dir in create_installer (input_path , tmp_path , with_spaces = True ):
855- _run_installer (
856- input_path ,
857- installer ,
858- install_dir ,
859- request = request ,
860- check_sentinels = CONSTRUCTOR_VERBOSE ,
861- check_subprocess = CONSTRUCTOR_VERBOSE ,
862- )
864+ installer , install_dir = create_single_installer (
865+ input_path , tmp_path , installer_type , with_spaces = True
866+ )
867+ _run_installer (
868+ input_path ,
869+ installer ,
870+ install_dir ,
871+ request = request ,
872+ check_sentinels = CONSTRUCTOR_VERBOSE ,
873+ check_subprocess = CONSTRUCTOR_VERBOSE ,
874+ )
863875
864876
865- def test_example_mirrored_channels (tmp_path , request ):
877+ @pytest .mark .parametrize (
878+ "installer_type" , installer_types_for_example (_example_path ("mirrored_channels" ))
879+ )
880+ def test_example_mirrored_channels (tmp_path , request , installer_type ):
866881 input_path = _example_path ("mirrored_channels" )
867- for installer , install_dir in create_installer (input_path , tmp_path ):
868- _run_installer (input_path , installer , install_dir , request = request , uninstall = False )
869-
870- expected_condarc = {
871- "channels" : ["conda-forge" ],
872- "mirrored_channels" : {
873- "conda-forge" : [
874- "https://conda.anaconda.org/conda-forge" ,
875- "https://conda.anaconda.org/mirror1" ,
876- "https://conda.anaconda.org/mirror2" ,
877- ]
878- },
879- }
882+ installer , install_dir = create_single_installer (input_path , tmp_path , installer_type )
883+ _run_installer (input_path , installer , install_dir , request = request , uninstall = False )
884+
885+ expected_condarc = {
886+ "channels" : ["conda-forge" ],
887+ "mirrored_channels" : {
888+ "conda-forge" : [
889+ "https://conda.anaconda.org/conda-forge" ,
890+ "https://conda.anaconda.org/mirror1" ,
891+ "https://conda.anaconda.org/mirror2" ,
892+ ]
893+ },
894+ }
880895
881- condarc_file = install_dir / ".condarc"
882- assert condarc_file .exists ()
896+ condarc_file = install_dir / ".condarc"
897+ assert condarc_file .exists ()
883898
884- with open (condarc_file ) as file :
885- condarc_data = YAML ().load (file )
899+ with open (condarc_file ) as file :
900+ condarc_data = YAML ().load (file )
886901
887- assert condarc_data == expected_condarc
902+ assert condarc_data == expected_condarc
888903
889904
890905def _check_miniforge (
@@ -978,18 +993,26 @@ def test_example_miniforge_mamba2(tmp_path, request, installer_type):
978993 )
979994
980995
981- def test_example_noconda (tmp_path , request ):
996+ @pytest .mark .parametrize (
997+ "installer_type" ,
998+ installer_types_for_example (_example_path ("noconda" ), "constructor_input.yaml" ),
999+ )
1000+ def test_example_noconda (tmp_path , request , installer_type ):
9821001 input_path = _example_path ("noconda" )
983- for installer , install_dir in create_installer (
984- input_path , tmp_path , config_filename = "constructor_input.yaml" , with_spaces = True
985- ):
986- _run_installer (
987- input_path ,
988- installer ,
989- install_dir ,
990- config_filename = "constructor_input.yaml" ,
991- request = request ,
992- )
1002+ installer , install_dir = create_single_installer (
1003+ input_path ,
1004+ tmp_path ,
1005+ installer_type ,
1006+ config_filename = "constructor_input.yaml" ,
1007+ with_spaces = True ,
1008+ )
1009+ _run_installer (
1010+ input_path ,
1011+ installer ,
1012+ install_dir ,
1013+ config_filename = "constructor_input.yaml" ,
1014+ request = request ,
1015+ )
9931016
9941017
9951018@pytest .mark .skipif (sys .platform != "darwin" , reason = "macOS only" )
@@ -1109,10 +1132,13 @@ def test_macos_signing(tmp_path, self_signed_application_certificate_macos):
11091132 assert validated_signatures == components
11101133
11111134
1112- def test_example_scripts (tmp_path , request ):
1135+ @pytest .mark .parametrize ("installer_type" , installer_types_for_example (_example_path ("scripts" )))
1136+ def test_example_scripts (tmp_path , request , installer_type ):
11131137 input_path = _example_path ("scripts" )
1114- for installer , install_dir in create_installer (input_path , tmp_path , with_spaces = True ):
1115- _run_installer (input_path , installer , install_dir , request = request )
1138+ installer , install_dir = create_single_installer (
1139+ input_path , tmp_path , installer_type , with_spaces = True
1140+ )
1141+ _run_installer (input_path , installer , install_dir , request = request )
11161142
11171143
11181144@pytest .mark .skipif (
@@ -1248,18 +1274,21 @@ def test_azure_signtool(tmp_path, request, monkeypatch, auth_method):
12481274 _run_installer (input_path , installer , install_dir , request = request )
12491275
12501276
1251- def test_example_use_channel_remap (tmp_path , request ):
1277+ @pytest .mark .parametrize (
1278+ "installer_type" , installer_types_for_example (_example_path ("use_channel_remap" ))
1279+ )
1280+ def test_example_use_channel_remap (tmp_path , request , installer_type ):
12521281 input_path = _example_path ("use_channel_remap" )
1253- for installer , install_dir in create_installer (input_path , tmp_path ):
1254- _run_installer (input_path , installer , install_dir , request = request , uninstall = False )
1255- p = subprocess .run (
1256- [sys .executable , "-m" , "conda" , "list" , "--prefix" , install_dir , "--json" ],
1257- capture_output = True ,
1258- text = True ,
1259- )
1260- packages = json .loads (p .stdout )
1261- for pkg in packages :
1262- assert pkg ["channel" ] == "private_repo"
1282+ installer , install_dir = create_single_installer (input_path , tmp_path , installer_type )
1283+ _run_installer (input_path , installer , install_dir , request = request , uninstall = False )
1284+ p = subprocess .run (
1285+ [sys .executable , "-m" , "conda" , "list" , "--prefix" , install_dir , "--json" ],
1286+ capture_output = True ,
1287+ text = True ,
1288+ )
1289+ packages = json .loads (p .stdout )
1290+ for pkg in packages :
1291+ assert pkg ["channel" ] == "private_repo"
12631292
12641293
12651294def test_example_from_existing_env (tmp_path , request ):
@@ -1317,13 +1346,16 @@ def test_example_from_explicit(tmp_path, request):
13171346 assert out == expected
13181347
13191348
1320- def test_register_envs (tmp_path , request ):
1349+ @pytest .mark .parametrize (
1350+ "installer_type" , installer_types_for_example (_example_path ("register_envs" ))
1351+ )
1352+ def test_register_envs (tmp_path , request , installer_type ):
13211353 """Verify that 'register_envs: False' results in the environment not being registered."""
13221354 input_path = _example_path ("register_envs" )
1323- for installer , install_dir in create_installer (input_path , tmp_path ):
1324- _run_installer (input_path , installer , install_dir , request = request )
1325- environments_txt = Path ("~/.conda/environments.txt" ).expanduser ().read_text ()
1326- assert str (install_dir ) not in environments_txt
1355+ installer , install_dir = create_single_installer (input_path , tmp_path , installer_type )
1356+ _run_installer (input_path , installer , install_dir , request = request )
1357+ environments_txt = Path ("~/.conda/environments.txt" ).expanduser ().read_text ()
1358+ assert str (install_dir ) not in environments_txt
13271359
13281360
13291361@pytest .mark .skipif (sys .platform != "darwin" , reason = "macOS only" )
@@ -1438,17 +1470,20 @@ def test_virtual_specs_failed(tmp_path, request):
14381470 assert msg in process .stdout + process .stderr
14391471
14401472
1441- def test_virtual_specs_ok (tmp_path , request ):
1473+ @pytest .mark .parametrize (
1474+ "installer_type" , installer_types_for_example (_example_path ("virtual_specs_ok" ))
1475+ )
1476+ def test_virtual_specs_ok (tmp_path , request , installer_type ):
14421477 input_path = _example_path ("virtual_specs_ok" )
1443- for installer , install_dir in create_installer (input_path , tmp_path ):
1444- _run_installer (
1445- input_path ,
1446- installer ,
1447- install_dir ,
1448- request = request ,
1449- check_subprocess = True ,
1450- uninstall = True ,
1451- )
1478+ installer , install_dir = create_single_installer (input_path , tmp_path , installer_type )
1479+ _run_installer (
1480+ input_path ,
1481+ installer ,
1482+ install_dir ,
1483+ request = request ,
1484+ check_subprocess = True ,
1485+ uninstall = True ,
1486+ )
14521487
14531488
14541489@pytest .mark .skipif (sys .platform .startswith ("win" ), reason = "Unix only" )
@@ -1860,58 +1895,62 @@ def test_uninstallation_standalone(
18601895 shutil .rmtree (system_rc .parent )
18611896
18621897
1863- def test_output_files (tmp_path ):
1898+ @pytest .mark .parametrize ("installer_type" , installer_types_for_example (_example_path ("outputs" )))
1899+ def test_output_files (tmp_path , installer_type ):
18641900 input_path = _example_path ("outputs" )
1865- for installer , _ in create_installer (input_path , tmp_path ):
1866- files_expected = [
1867- f"{ installer .name } .md5" ,
1868- f"{ installer .name } .sha256" ,
1869- "info.json" ,
1870- "licenses.json" ,
1871- "pkg-list.base.txt" ,
1872- "pkg-list.py310.txt" ,
1873- "lockfile.base.txt" ,
1874- "lockfile.py310.txt" ,
1875- ]
1876- files_not_expected = [
1877- "pkg-list.py311.txt" ,
1878- "lockfile.py311.txt" ,
1879- ]
1880- root_path = installer .parent
1881- files_exist = [file for file in files_expected if (root_path / file ).exists ()]
1882- assert sorted (files_exist ) == sorted (files_expected )
1883- files_exist = [file for file in files_not_expected if (root_path / file ).exists ()]
1884- assert files_exist == []
1885-
1886- # Test that info.json contains serialized objects
1887- info_json = json .loads ((root_path / "info.json" ).read_text ())
1888- assert isinstance (info_json .get ("_conda_exe_version" ), str )
1889- _all_pkg_records = info_json .get ("_all_pkg_records" )
1890- assert isinstance (_all_pkg_records , list ), "Package record is not a list."
1891- assert len (_all_pkg_records ) > 0 , "Package record is empty."
1892- assert isinstance (_all_pkg_records [0 ], dict ), "Package record not serialized."
1893- _records = info_json .get ("_records" )
1894- assert isinstance (_records , list ), "Package record for base is not a list."
1895- assert len (_records ) > 0 , "Package record for base is empty."
1896- assert isinstance (_records [0 ], dict ), "Package record for base is not serialized."
1897- for env , env_info in info_json .get ("_extra_envs_info" , {}).items ():
1898- _records = env_info .get ("_records" )
1899- assert isinstance (_records , list ), f"Record for { env } is not a list."
1900- assert len (_records ) > 0 , f"Record for { env } is empty."
1901- assert isinstance (_records [0 ], dict ), f"Record for { env } is not serialized."
1902-
1903-
1904- def test_regressions (tmp_path , request ):
1901+ installer , _ = create_single_installer (input_path , tmp_path , installer_type )
1902+ files_expected = [
1903+ f"{ installer .name } .md5" ,
1904+ f"{ installer .name } .sha256" ,
1905+ "info.json" ,
1906+ "licenses.json" ,
1907+ "pkg-list.base.txt" ,
1908+ "pkg-list.py310.txt" ,
1909+ "lockfile.base.txt" ,
1910+ "lockfile.py310.txt" ,
1911+ ]
1912+ files_not_expected = [
1913+ "pkg-list.py311.txt" ,
1914+ "lockfile.py311.txt" ,
1915+ ]
1916+ root_path = installer .parent
1917+ files_exist = [file for file in files_expected if (root_path / file ).exists ()]
1918+ assert sorted (files_exist ) == sorted (files_expected )
1919+ files_exist = [file for file in files_not_expected if (root_path / file ).exists ()]
1920+ assert files_exist == []
1921+
1922+ # Test that info.json contains serialized objects
1923+ info_json = json .loads ((root_path / "info.json" ).read_text ())
1924+ assert isinstance (info_json .get ("_conda_exe_version" ), str )
1925+ _all_pkg_records = info_json .get ("_all_pkg_records" )
1926+ assert isinstance (_all_pkg_records , list ), "Package record is not a list."
1927+ assert len (_all_pkg_records ) > 0 , "Package record is empty."
1928+ assert isinstance (_all_pkg_records [0 ], dict ), "Package record not serialized."
1929+ _records = info_json .get ("_records" )
1930+ assert isinstance (_records , list ), "Package record for base is not a list."
1931+ assert len (_records ) > 0 , "Package record for base is empty."
1932+ assert isinstance (_records [0 ], dict ), "Package record for base is not serialized."
1933+ for env , env_info in info_json .get ("_extra_envs_info" , {}).items ():
1934+ _records = env_info .get ("_records" )
1935+ assert isinstance (_records , list ), f"Record for { env } is not a list."
1936+ assert len (_records ) > 0 , f"Record for { env } is empty."
1937+ assert isinstance (_records [0 ], dict ), f"Record for { env } is not serialized."
1938+
1939+
1940+ @pytest .mark .parametrize (
1941+ "installer_type" , installer_types_for_example (_example_path ("regressions" ))
1942+ )
1943+ def test_regressions (tmp_path , request , installer_type ):
19051944 input_path = _example_path ("regressions" )
1906- for installer , install_dir in create_installer (input_path , tmp_path ):
1907- _run_installer (
1908- input_path ,
1909- installer ,
1910- install_dir ,
1911- request = request ,
1912- check_subprocess = True ,
1913- uninstall = True ,
1914- )
1945+ installer , install_dir = create_single_installer (input_path , tmp_path , installer_type )
1946+ _run_installer (
1947+ input_path ,
1948+ installer ,
1949+ install_dir ,
1950+ request = request ,
1951+ check_subprocess = True ,
1952+ uninstall = True ,
1953+ )
19151954
19161955
19171956@pytest .mark .parametrize ("no_registry" , (0 , 1 ))
0 commit comments