From eb8001560400b94ed8ad10d681e9fda350220299 Mon Sep 17 00:00:00 2001 From: Srinivas Lade Date: Sun, 26 Feb 2023 14:43:51 -0500 Subject: [PATCH] Add a Multi-Source Test --- tests/test-multi-sources/dev.yml | 2 ++ tests/test-multi-sources/main.yml | 6 ++++++ tests/test-multi-sources/pyproject.toml | 18 ++++++++++++++++++ tests/test_conda_lock.py | 12 ++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 tests/test-multi-sources/dev.yml create mode 100644 tests/test-multi-sources/main.yml create mode 100644 tests/test-multi-sources/pyproject.toml diff --git a/tests/test-multi-sources/dev.yml b/tests/test-multi-sources/dev.yml new file mode 100644 index 000000000..473a9ad7b --- /dev/null +++ b/tests/test-multi-sources/dev.yml @@ -0,0 +1,2 @@ +dependencies: + - pytest diff --git a/tests/test-multi-sources/main.yml b/tests/test-multi-sources/main.yml new file mode 100644 index 000000000..e1a68acd3 --- /dev/null +++ b/tests/test-multi-sources/main.yml @@ -0,0 +1,6 @@ +dependencies: + - python <3.11 +platforms: + - osx-arm64 + - osx-64 + - linux-64 diff --git a/tests/test-multi-sources/pyproject.toml b/tests/test-multi-sources/pyproject.toml new file mode 100644 index 000000000..06246cbab --- /dev/null +++ b/tests/test-multi-sources/pyproject.toml @@ -0,0 +1,18 @@ +[tool.poetry] +name = "conda-lock-test-poetry" +version = "0.0.1" +description = "" +authors = ["conda-lock"] + +[tool.poetry.dependencies] +pandas = "^1.5.0" + +[build-system] +requires = ["poetry>=0.12"] +build-backend = "poetry.masonry.api" + +[tool.conda-lock] +platforms = [ + "win-64", + "osx-arm64" +] diff --git a/tests/test_conda_lock.py b/tests/test_conda_lock.py index 2883a1af8..943ac8789 100644 --- a/tests/test_conda_lock.py +++ b/tests/test_conda_lock.py @@ -67,6 +67,7 @@ from conda_lock.src_parser import ( DEFAULT_PLATFORMS, LockSpecification, + _parse_platforms_from_srcs, parse_meta_yaml_file, ) from conda_lock.src_parser.aggregation import aggregate_lock_specs @@ -215,6 +216,12 @@ def git_metadata_zlib_environment(tmp_path: Path): return clone_test_dir("zlib", tmp_path).joinpath("environment.yml") +@pytest.fixture +def multi_source_env(tmp_path: Path): + f = clone_test_dir("test-multi-sources", tmp_path) + return [f.joinpath("main.yml"), f.joinpath("pyproject.toml"), f.joinpath("dev.yml")] + + @pytest.fixture( scope="function", params=[ @@ -427,6 +434,11 @@ def test_parse_env_file_with_filters_defaults(filter_conda_environment: Path): ) +def test_parse_platforms_from_multi_sources(multi_source_env): + platforms = _parse_platforms_from_srcs(multi_source_env) + assert platforms == ["osx-arm64", "osx-64", "linux-64", "win-64"] + + def test_choose_wheel() -> None: solution = solve_pypi( {