MCPcopy
hub / github.com/conda/conda / test_channel_usage_replacing_python

Function test_channel_usage_replacing_python

tests/test_create.py:1117–1168  ·  view source on GitHub ↗
(
    tmp_env: TmpEnvFixture,
    conda_cli: CondaCLIFixture,
)

Source from the content-addressed store, hash-verified

1115
1116
1117def test_channel_usage_replacing_python(
1118 tmp_env: TmpEnvFixture,
1119 conda_cli: CondaCLIFixture,
1120):
1121 # Regression test for #2606
1122 with tmp_env("--channel=conda-forge", PYTHON_SPEC) as prefix:
1123 assert (prefix / PYTHON_BINARY).exists()
1124 assert package_is_installed(prefix, f"conda-forge::{PYTHON_SPEC}")
1125
1126 conda_cli(
1127 "install",
1128 f"--prefix={prefix}",
1129 "--channel=main",
1130 "decorator",
1131 "--yes",
1132 )
1133 PrefixData._cache_.clear()
1134 if context.solver == "rattler":
1135 # Rattler adjustment: channels change more than expected
1136 assert (prec := package_is_installed(prefix, PYTHON_SPEC))
1137 assert package_is_installed(prefix, "decorator")
1138 else:
1139 assert (prec := package_is_installed(prefix, f"conda-forge::{PYTHON_SPEC}"))
1140 assert package_is_installed(prefix, "main::decorator")
1141
1142 with tmp_env(f"--clone={prefix}") as clone:
1143 if context.solver == "rattler":
1144 # Rattler adjustment: channels change more than expected
1145 assert package_is_installed(clone, PYTHON_SPEC)
1146 assert package_is_installed(clone, "decorator")
1147 else:
1148 assert package_is_installed(clone, f"conda-forge::{PYTHON_SPEC}")
1149 assert package_is_installed(clone, "main::decorator")
1150
1151 # Regression test for #2645
1152 fn = prefix / "conda-meta" / f"{prec.name}-{prec.version}-{prec.build}.json"
1153 data = {
1154 field: value
1155 for field, value in json.loads(fn.read_text()).items()
1156 if field not in ("url", "channel", "schannel", "channel_name")
1157 }
1158 fn.write_text(json.dumps(data))
1159 PrefixData._cache_.clear()
1160
1161 with tmp_env("--channel=conda-forge", f"--clone={prefix}") as clone:
1162 if context.solver == "rattler":
1163 # Rattler adjustment: channels change more than expected
1164 assert package_is_installed(clone, PYTHON_SPEC)
1165 assert package_is_installed(clone, "decorator")
1166 else:
1167 assert package_is_installed(clone, f"conda-forge::{PYTHON_SPEC}")
1168 assert package_is_installed(clone, "main::decorator")
1169
1170
1171def test_install_prune_flag(tmp_env: TmpEnvFixture, conda_cli: CondaCLIFixture):

Callers

nothing calls this directly

Calls 6

package_is_installedFunction · 0.90
tmp_envFunction · 0.85
conda_cliFunction · 0.85
itemsMethod · 0.80
existsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…