Skip to content

Commit

Permalink
test: PyPI packages in environment export
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <[email protected]>
  • Loading branch information
jjerphan committed Nov 20, 2024
1 parent e1e0f8c commit 9f29377
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions micromamba/tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,36 @@ def test_env_update_empty_base(tmp_home, tmp_root_prefix, tmp_path):
packages = helpers.umamba_list("-p", env_prefix, "--json")
assert any(package["name"] == "xtensor" for package in packages)
assert any(package["name"] == "python" for package in packages)


env_yaml_content_to_install_numpy_with_pip = """
channels:
- conda-forge
dependencies:
- pip
- pip:
- numpy==1.26.4
"""


@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_env_export_with_pip(tmp_home, tmp_root_prefix, tmp_path):
env_name = "env-list_with_pip"
tmp_root_prefix / "envs" / env_name

env_file_yml = tmp_path / "test_env_yaml_content_to_install_numpy_with_pip.yaml"
env_file_yml.write_text(env_yaml_content_to_install_numpy_with_pip)

helpers.create("-n", env_name, "test_env_export_with_pip", "--json", no_dry_run=True)
helpers.install("-n", env_name, "-f", env_file_yml, "--json", no_dry_run=True)

output = helpers.run_env("export", "-n", env_name, "--json")
ret = yaml.safe_load(output)

assert ret["name"] == env_name
assert env_name in ret["prefix"]
assert set(ret["channels"]) == {"conda-forge"}
assert any("pip" in dep for dep in ret["dependencies"])

# Check that numpy is exported under the pip subsection of the dependencies
assert any("numpy" in dep for dep in ret["dependencies"]["pip"])

0 comments on commit 9f29377

Please sign in to comment.