From 157f2290c7077c9129cb63caaf7f8294781093c6 Mon Sep 17 00:00:00 2001 From: Albert DeFusco Date: Fri, 19 May 2023 14:16:42 -0500 Subject: [PATCH 01/10] move init tests to separate file --- tests/test_init.py | 156 ++++++++++++++++++++++++++++++++++++++++++ tests/test_project.py | 146 --------------------------------------- 2 files changed, 156 insertions(+), 146 deletions(-) create mode 100644 tests/test_init.py diff --git a/tests/test_init.py b/tests/test_init.py new file mode 100644 index 00000000..3889ce21 --- /dev/null +++ b/tests/test_init.py @@ -0,0 +1,156 @@ +# Copyright (C) 2022 Anaconda, Inc +# SPDX-License-Identifier: BSD-3-Clause +import logging +import os +from textwrap import dedent + +import pytest +from ruamel.yaml import YAML + +from conda_project.exceptions import CondaProjectError +from conda_project.project import DEFAULT_PLATFORMS, CondaProject + + +def test_project_init_new_directory(tmp_path, capsys): + project_directory = tmp_path / "new-project" + assert not os.path.exists(project_directory) + + p = CondaProject.init(project_directory, lock_dependencies=False, verbose=True) + + assert os.path.exists(project_directory) + assert p.project_yaml_path.exists() + assert p.default_environment.sources[0].exists() + assert not p.default_environment.is_locked + + assert p.condarc.exists() + with p.condarc.open() as f: + condarc = YAML().load(f) + assert condarc == {} + + out, _ = capsys.readouterr() + assert f"Project created at {project_directory}\n" == out + + +def test_project_init_twice(tmp_path, capsys): + _ = CondaProject.init(tmp_path, lock_dependencies=False) + p = CondaProject.init(tmp_path, lock_dependencies=False, verbose=True) + + out, _ = capsys.readouterr() + assert f"Existing project file found at {p.project_yaml_path}.\n" == out + + +def test_project_init_default_platforms(tmp_path): + p = CondaProject.init(tmp_path, lock_dependencies=False) + + with p.default_environment.sources[0].open() as f: + env = YAML().load(f) + + assert env["platforms"] == list(DEFAULT_PLATFORMS) + + +def test_project_init_specific_platforms(tmp_path): + p = CondaProject.init(tmp_path, platforms=["linux-64"], lock_dependencies=False) + + with p.default_environment.sources[0].open() as f: + env = YAML().load(f) + + assert env["platforms"] == ["linux-64"] + + +def test_project_init_specific_channels(tmp_path): + p = CondaProject.init( + tmp_path, + dependencies=["python=3.8", "numpy"], + channels=["conda-forge", "defaults"], + lock_dependencies=False, + ) + + with p.default_environment.sources[0].open() as f: + env = YAML().load(f) + + assert env["dependencies"] == ["python=3.8", "numpy"] + assert env["channels"] == ["conda-forge", "defaults"] + + +def test_project_init_default_channel(tmp_path): + p = CondaProject.init( + tmp_path, dependencies=["python=3.8", "numpy"], lock_dependencies=False + ) + + with p.default_environment.sources[0].open() as f: + env = YAML().load(f) + + assert env["dependencies"] == ["python=3.8", "numpy"] + assert env["channels"] == ["defaults"] + + +def test_project_init_conda_configs(tmp_path): + p = CondaProject.init( + tmp_path, + dependencies=["python=3.8", "numpy"], + conda_configs=["experimental_solver=libmamba"], + lock_dependencies=False, + ) + + with p.condarc.open() as f: + condarc = YAML().load(f) + + assert condarc["experimental_solver"] == "libmamba" + + +@pytest.mark.slow +def test_project_init_and_lock(tmp_path): + p = CondaProject.init(tmp_path, dependencies=["python=3.8"], lock_dependencies=True) + assert p.default_environment.lockfile.exists() + assert p.default_environment.lockfile == tmp_path / "conda-lock.default.yml" + + +def test_conda_project_init_empty_dir(tmp_path, caplog): + caplog.set_level(logging.INFO) + + with pytest.raises(CondaProjectError) as excinfo: + CondaProject(tmp_path) + assert "No conda environment.yml or environment.yaml file was found" in str( + excinfo.value + ) + + assert "No conda-project.yml or conda-project.yaml file was found" in caplog.text + + +def test_conda_project_init_with_env_yaml(project_directory_factory): + env_yaml = dedent( + """\ + name: test + dependencies: [] + """ + ) + project_path = project_directory_factory(env_yaml=env_yaml) + project = CondaProject(project_path) + + assert project.default_environment == project.environments["default"] + + assert ( + project.default_environment.lockfile + == project.directory / "conda-lock.default.yml" + ) + assert project.default_environment.sources == ( + (project.directory / "environment").with_suffix( + project_directory_factory._suffix + ), + ) + assert project.default_environment.prefix == project.directory / "envs" / "default" + + +def test_project_init_expands_cwd(monkeypatch, project_directory_factory): + project_path = project_directory_factory(env_yaml="") + monkeypatch.chdir(project_path) + + project = CondaProject() + assert project.directory.samefile(project_path) + + +def test_project_init_path(project_directory_factory): + project_path = project_directory_factory(env_yaml="") + + project = CondaProject(project_path) + assert project.directory.samefile(project_path) diff --git a/tests/test_project.py b/tests/test_project.py index d3567628..a6b3a246 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -2,7 +2,6 @@ # Copyright (C) 2022 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause import json -import logging import os from pathlib import Path from textwrap import dedent @@ -24,151 +23,6 @@ def is_libmamba_installed(): return False -def test_project_create_new_directory(tmp_path, capsys): - project_directory = tmp_path / "new-project" - assert not os.path.exists(project_directory) - - p = CondaProject.init(project_directory, lock_dependencies=False, verbose=True) - - assert os.path.exists(project_directory) - assert p.project_yaml_path.exists() - assert p.default_environment.sources[0].exists() - assert not p.default_environment.is_locked - - assert p.condarc.exists() - with p.condarc.open() as f: - condarc = YAML().load(f) - assert condarc == {} - - out, _ = capsys.readouterr() - assert f"Project created at {project_directory}\n" == out - - -def test_project_create_twice(tmp_path, capsys): - _ = CondaProject.init(tmp_path, lock_dependencies=False) - p = CondaProject.init(tmp_path, lock_dependencies=False, verbose=True) - - out, _ = capsys.readouterr() - assert f"Existing project file found at {p.project_yaml_path}.\n" == out - - -def test_project_create_default_platforms(tmp_path): - p = CondaProject.init(tmp_path, lock_dependencies=False) - - with p.default_environment.sources[0].open() as f: - env = YAML().load(f) - - assert env["platforms"] == list(DEFAULT_PLATFORMS) - - -def test_project_create_specific_platforms(tmp_path): - p = CondaProject.init(tmp_path, platforms=["linux-64"], lock_dependencies=False) - - with p.default_environment.sources[0].open() as f: - env = YAML().load(f) - - assert env["platforms"] == ["linux-64"] - - -def test_project_create_specific_channels(tmp_path): - p = CondaProject.init( - tmp_path, - dependencies=["python=3.8", "numpy"], - channels=["conda-forge", "defaults"], - lock_dependencies=False, - ) - - with p.default_environment.sources[0].open() as f: - env = YAML().load(f) - - assert env["dependencies"] == ["python=3.8", "numpy"] - assert env["channels"] == ["conda-forge", "defaults"] - - -def test_project_create_default_channel(tmp_path): - p = CondaProject.init( - tmp_path, dependencies=["python=3.8", "numpy"], lock_dependencies=False - ) - - with p.default_environment.sources[0].open() as f: - env = YAML().load(f) - - assert env["dependencies"] == ["python=3.8", "numpy"] - assert env["channels"] == ["defaults"] - - -def test_project_create_conda_configs(tmp_path): - p = CondaProject.init( - tmp_path, - dependencies=["python=3.8", "numpy"], - conda_configs=["experimental_solver=libmamba"], - lock_dependencies=False, - ) - - with p.condarc.open() as f: - condarc = YAML().load(f) - - assert condarc["experimental_solver"] == "libmamba" - - -@pytest.mark.slow -def test_project_create_and_lock(tmp_path): - p = CondaProject.init(tmp_path, dependencies=["python=3.8"], lock_dependencies=True) - assert p.default_environment.lockfile.exists() - assert p.default_environment.lockfile == tmp_path / "conda-lock.default.yml" - - -def test_conda_project_init_empty_dir(tmp_path, caplog): - caplog.set_level(logging.INFO) - - with pytest.raises(CondaProjectError) as excinfo: - CondaProject(tmp_path) - assert "No conda environment.yml or environment.yaml file was found" in str( - excinfo.value - ) - - assert "No conda-project.yml or conda-project.yaml file was found" in caplog.text - - -def test_conda_project_init_with_env_yaml(project_directory_factory): - env_yaml = dedent( - """\ - name: test - dependencies: [] - """ - ) - project_path = project_directory_factory(env_yaml=env_yaml) - project = CondaProject(project_path) - - assert project.default_environment == project.environments["default"] - - assert ( - project.default_environment.lockfile - == project.directory / "conda-lock.default.yml" - ) - assert project.default_environment.sources == ( - (project.directory / "environment").with_suffix( - project_directory_factory._suffix - ), - ) - assert project.default_environment.prefix == project.directory / "envs" / "default" - - -def test_project_init_expands_cwd(monkeypatch, project_directory_factory): - project_path = project_directory_factory(env_yaml="") - monkeypatch.chdir(project_path) - - project = CondaProject() - assert project.directory.samefile(project_path) - - -def test_project_init_path(project_directory_factory): - project_path = project_directory_factory(env_yaml="") - - project = CondaProject(project_path) - assert project.directory.samefile(project_path) - - def test_prepare_with_gitignore(project_directory_factory): env_yaml = dedent( """\ From 1c145921e26cf15336344bcbd892ba86a1345cde Mon Sep 17 00:00:00 2001 From: Albert DeFusco Date: Fri, 19 May 2023 15:24:42 -0500 Subject: [PATCH 02/10] ensure expanduser is done for paths completed and tested in * CondaProject.__init__ * CondaProject.init * CondaProject.from_archive --- src/conda_project/project.py | 7 ++++--- tests/test_archive.py | 29 +++++++++++++++++++++++++++++ tests/test_init.py | 27 +++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/conda_project/project.py b/src/conda_project/project.py index a462a4a2..d5293baa 100644 --- a/src/conda_project/project.py +++ b/src/conda_project/project.py @@ -111,7 +111,7 @@ class CondaProject: """ def __init__(self, directory: Union[Path, str] = "."): - self.directory = Path(directory).resolve() + self.directory = Path(directory).expanduser().resolve() logger.info(f"created Project instance at {self.directory}") self.project_yaml_path = find_file(self.directory, PROJECT_YAML_FILENAMES) @@ -149,13 +149,14 @@ def from_archive( """Extra a conda-project archive and load the project""" if isinstance(output_directory, str): - output_directory = Path(output_directory) + output_directory = Path(output_directory).expanduser() storage_options = {} if storage_options is None else storage_options protocol, _ = split_protocol(fn) if protocol is not None: options = {protocol: storage_options} else: + fn = Path(fn).expanduser() options = {} files = fsspec.open_files(f"libarchive://**::{fn}", **options) @@ -243,7 +244,7 @@ def init( """ - directory = Path(directory).resolve() + directory = Path(directory).expanduser().resolve() if not directory.exists(): directory.mkdir(parents=True) diff --git a/tests/test_archive.py b/tests/test_archive.py index 592bf7d7..cb3b80ff 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -123,3 +123,32 @@ def test_archive_storage_options(mocker): assert mocked_open_files.call_args_list[0].kwargs == { "file": {"key1": "valueA", "key2": "valueB"} } + + +def test_archive_path_expanduser(mocker): + from pathlib import Path + + expanduser = mocker.spy(Path, "expanduser") + + archive = "~__a-conda-project-user__/project.tar.gz" + with pytest.raises(RuntimeError): + _ = CondaProject.from_archive(fn=archive) + + assert expanduser.call_count == 2 + assert str(expanduser.call_args_list[0].args[0]) == "." + assert str(expanduser.call_args_list[1].args[0]) == archive + + +def test_archive_output_directory_expanduser(mocker): + from pathlib import Path + + expanduser = mocker.spy(Path, "expanduser") + + archive = ASSETS_DIR / "top-level-dir.tar.gz" + + output_directory = "~__a-conda-project-user__/project" + with pytest.raises(RuntimeError): + _ = CondaProject.from_archive(fn=archive, output_directory=output_directory) + + assert expanduser.call_count == 1 + assert str(expanduser.call_args_list[0].args[0]) == output_directory diff --git a/tests/test_init.py b/tests/test_init.py index 3889ce21..7e40773d 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -11,6 +11,20 @@ from conda_project.project import DEFAULT_PLATFORMS, CondaProject +def test_project_init_expanduser(mocker): + from pathlib import Path + + expanduser = mocker.spy(Path, "expanduser") + + project_directory = "~__a-conda-project-user__/project" + + with pytest.raises(RuntimeError): + _ = CondaProject(project_directory) + + assert expanduser.call_count == 1 + assert str(expanduser.call_args_list[0].args[0]) == project_directory + + def test_project_init_new_directory(tmp_path, capsys): project_directory = tmp_path / "new-project" assert not os.path.exists(project_directory) @@ -105,6 +119,19 @@ def test_project_init_and_lock(tmp_path): assert p.default_environment.lockfile == tmp_path / "conda-lock.default.yml" +def test_project_directory_expanduser(mocker): + from pathlib import Path + + expanduser = mocker.spy(Path, "expanduser") + + directory = "~__a-conda-project-user__/project" + with pytest.raises(RuntimeError): + _ = CondaProject(directory) + + assert expanduser.call_count == 1 + assert str(expanduser.call_args_list[0].args[0]) == directory + + def test_conda_project_init_empty_dir(tmp_path, caplog): caplog.set_level(logging.INFO) From bd507b5297aa7f1e6eea54c591cfa9596db8b741 Mon Sep 17 00:00:00 2001 From: Albert DeFusco Date: Fri, 19 May 2023 15:57:19 -0500 Subject: [PATCH 03/10] prepend simple cache if a protocol is used a protocol-prepended url is something like file:///... https://... s3://... and sometimes these sources don't always support seeking. Using simplecache ensures that the whole archive is brought into local disk before extraction. --- src/conda_project/project.py | 1 + tests/test_archive.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/conda_project/project.py b/src/conda_project/project.py index d5293baa..a14da16c 100644 --- a/src/conda_project/project.py +++ b/src/conda_project/project.py @@ -155,6 +155,7 @@ def from_archive( protocol, _ = split_protocol(fn) if protocol is not None: options = {protocol: storage_options} + fn = f"simplecache::{fn}" else: fn = Path(fn).expanduser() options = {} diff --git a/tests/test_archive.py b/tests/test_archive.py index cb3b80ff..2dbedda9 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -123,6 +123,7 @@ def test_archive_storage_options(mocker): assert mocked_open_files.call_args_list[0].kwargs == { "file": {"key1": "valueA", "key2": "valueB"} } + assert "simplecache" in mocked_open_files.call_args_list[0].args[0] def test_archive_path_expanduser(mocker): From 3ebd5c715561c3734a3e028a4e09a21a76770107 Mon Sep 17 00:00:00 2001 From: Albert DeFusco Date: Fri, 19 May 2023 17:12:12 -0500 Subject: [PATCH 04/10] windows raises FileNotFoundError --- tests/test_archive.py | 4 ++-- tests/test_init.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_archive.py b/tests/test_archive.py index 2dbedda9..aabb69fe 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -132,7 +132,7 @@ def test_archive_path_expanduser(mocker): expanduser = mocker.spy(Path, "expanduser") archive = "~__a-conda-project-user__/project.tar.gz" - with pytest.raises(RuntimeError): + with pytest.raises((RuntimeError, FileNotFoundError)): _ = CondaProject.from_archive(fn=archive) assert expanduser.call_count == 2 @@ -148,7 +148,7 @@ def test_archive_output_directory_expanduser(mocker): archive = ASSETS_DIR / "top-level-dir.tar.gz" output_directory = "~__a-conda-project-user__/project" - with pytest.raises(RuntimeError): + with pytest.raises((RuntimeError, FileNotFoundError)): _ = CondaProject.from_archive(fn=archive, output_directory=output_directory) assert expanduser.call_count == 1 diff --git a/tests/test_init.py b/tests/test_init.py index 7e40773d..ed50f53e 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -18,7 +18,7 @@ def test_project_init_expanduser(mocker): project_directory = "~__a-conda-project-user__/project" - with pytest.raises(RuntimeError): + with pytest.raises((RuntimeError, FileNotFoundError)): _ = CondaProject(project_directory) assert expanduser.call_count == 1 @@ -125,7 +125,7 @@ def test_project_directory_expanduser(mocker): expanduser = mocker.spy(Path, "expanduser") directory = "~__a-conda-project-user__/project" - with pytest.raises(RuntimeError): + with pytest.raises((RuntimeError, FileNotFoundError)): _ = CondaProject(directory) assert expanduser.call_count == 1 From 1153836b4a5265655041b86317abb782f7fb4c2f Mon Sep 17 00:00:00 2001 From: Albert DeFusco Date: Mon, 22 May 2023 14:43:48 -0500 Subject: [PATCH 05/10] drop isinstance check for Paths also drop string comparison in tests --- src/conda_project/project.py | 3 +-- tests/test_archive.py | 3 --- tests/test_init.py | 4 +--- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/conda_project/project.py b/src/conda_project/project.py index a14da16c..65e09f6a 100644 --- a/src/conda_project/project.py +++ b/src/conda_project/project.py @@ -148,8 +148,7 @@ def from_archive( ): """Extra a conda-project archive and load the project""" - if isinstance(output_directory, str): - output_directory = Path(output_directory).expanduser() + output_directory = Path(output_directory).expanduser() storage_options = {} if storage_options is None else storage_options protocol, _ = split_protocol(fn) diff --git a/tests/test_archive.py b/tests/test_archive.py index aabb69fe..d9cb30c2 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -136,8 +136,6 @@ def test_archive_path_expanduser(mocker): _ = CondaProject.from_archive(fn=archive) assert expanduser.call_count == 2 - assert str(expanduser.call_args_list[0].args[0]) == "." - assert str(expanduser.call_args_list[1].args[0]) == archive def test_archive_output_directory_expanduser(mocker): @@ -152,4 +150,3 @@ def test_archive_output_directory_expanduser(mocker): _ = CondaProject.from_archive(fn=archive, output_directory=output_directory) assert expanduser.call_count == 1 - assert str(expanduser.call_args_list[0].args[0]) == output_directory diff --git a/tests/test_init.py b/tests/test_init.py index ed50f53e..862b7a39 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -22,7 +22,6 @@ def test_project_init_expanduser(mocker): _ = CondaProject(project_directory) assert expanduser.call_count == 1 - assert str(expanduser.call_args_list[0].args[0]) == project_directory def test_project_init_new_directory(tmp_path, capsys): @@ -129,7 +128,6 @@ def test_project_directory_expanduser(mocker): _ = CondaProject(directory) assert expanduser.call_count == 1 - assert str(expanduser.call_args_list[0].args[0]) == directory def test_conda_project_init_empty_dir(tmp_path, caplog): @@ -168,7 +166,7 @@ def test_conda_project_init_with_env_yaml(project_directory_factory): assert project.default_environment.prefix == project.directory / "envs" / "default" -def test_project_init_expands_cwd(monkeypatch, project_directory_factory): +def test_project_init_resolves_cwd(monkeypatch, project_directory_factory): project_path = project_directory_factory(env_yaml="") monkeypatch.chdir(project_path) From 45af9fa64f8277cdc36184fb735146a87cfdcf5f Mon Sep 17 00:00:00 2001 From: Albert DeFusco Date: Tue, 23 May 2023 12:56:53 -0500 Subject: [PATCH 06/10] still fixing windows exception tests it seems that I haven't found out how to tell pytests.raises that the block may raise "one of" a collection of exceptions. --- tests/test_archive.py | 17 +++++++++++++---- tests/test_init.py | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/tests/test_archive.py b/tests/test_archive.py index d9cb30c2..231238ef 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -7,6 +7,7 @@ from conda_project.exceptions import CondaProjectError from conda_project.project import CondaProject +from conda_project.utils import is_windows ASSETS_DIR = Path(__file__).parents[0] / "assets" @@ -132,8 +133,12 @@ def test_archive_path_expanduser(mocker): expanduser = mocker.spy(Path, "expanduser") archive = "~__a-conda-project-user__/project.tar.gz" - with pytest.raises((RuntimeError, FileNotFoundError)): - _ = CondaProject.from_archive(fn=archive) + if is_windows(): + with pytest.raises(FileNotFoundError): + _ = CondaProject.from_archive(fn=archive) + else: + with pytest.raises(RuntimeError): + _ = CondaProject.from_archive(fn=archive) assert expanduser.call_count == 2 @@ -146,7 +151,11 @@ def test_archive_output_directory_expanduser(mocker): archive = ASSETS_DIR / "top-level-dir.tar.gz" output_directory = "~__a-conda-project-user__/project" - with pytest.raises((RuntimeError, FileNotFoundError)): - _ = CondaProject.from_archive(fn=archive, output_directory=output_directory) + if is_windows(): + with pytest.raises(FileNotFoundError): + _ = CondaProject.from_archive(fn=archive, output_directory=output_directory) + else: + with pytest.raises(RuntimeError): + _ = CondaProject.from_archive(fn=archive, output_directory=output_directory) assert expanduser.call_count == 1 diff --git a/tests/test_init.py b/tests/test_init.py index 862b7a39..c7632bf4 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -9,6 +9,7 @@ from conda_project.exceptions import CondaProjectError from conda_project.project import DEFAULT_PLATFORMS, CondaProject +from conda_project.utils import is_windows def test_project_init_expanduser(mocker): @@ -18,8 +19,12 @@ def test_project_init_expanduser(mocker): project_directory = "~__a-conda-project-user__/project" - with pytest.raises((RuntimeError, FileNotFoundError)): - _ = CondaProject(project_directory) + if is_windows(): + with pytest.raises(FileNotFoundError): + _ = CondaProject(project_directory) + else: + with pytest.raises(RuntimeError): + _ = CondaProject(project_directory) assert expanduser.call_count == 1 @@ -124,8 +129,12 @@ def test_project_directory_expanduser(mocker): expanduser = mocker.spy(Path, "expanduser") directory = "~__a-conda-project-user__/project" - with pytest.raises((RuntimeError, FileNotFoundError)): - _ = CondaProject(directory) + if is_windows(): + with pytest.raises(FileNotFoundError): + _ = CondaProject(directory) + else: + with pytest.raises(RuntimeError): + _ = CondaProject(directory) assert expanduser.call_count == 1 From 7ee5819e3f9771b6976518e1536838550186377a Mon Sep 17 00:00:00 2001 From: Albert DeFusco Date: Wed, 24 May 2023 15:26:00 -0500 Subject: [PATCH 07/10] correct for conda-lock #414 to avoid a failure in conda-lock for repodata changes at repo.anaconda.com, restrict to installing from conda-forge --- .github/workflows/main.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 79afa94e..1ee7c067 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -16,6 +16,8 @@ on: - "docs/**" branches: - main + + jobs: package: name: Build package @@ -59,6 +61,7 @@ jobs: env: OS: ${{ matrix.os }} PYTHON: ${{ matrix.python-version }} + CONDA_DEFAULT_CHANNELS: conda-forge steps: - uses: actions/checkout@v3 - name: Download conda standalone From 306b525b822f40755e79458238594079245d2b73 Mon Sep 17 00:00:00 2001 From: Albert DeFusco Date: Wed, 24 May 2023 16:17:42 -0500 Subject: [PATCH 08/10] something was not happy an error came out of cachecontrol through the vendored poetry in conda-lock. The conda-lock fix env var has been moved lower into the invocation of pytest. --- .github/workflows/main.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 1ee7c067..c13fc83f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -61,7 +61,6 @@ jobs: env: OS: ${{ matrix.os }} PYTHON: ${{ matrix.python-version }} - CONDA_DEFAULT_CHANNELS: conda-forge steps: - uses: actions/checkout@v3 - name: Download conda standalone @@ -82,6 +81,9 @@ jobs: shell: bash run: | ./conda.exe create -p $HOME/miniconda conda=${{ matrix.conda-version }} python=${{ matrix.python-version }} + - name: Update with test dependencies + shell: bash + run: | if [ $RUNNER_OS == 'Windows' ]; then source $HOME/miniconda/Scripts/activate root && conda env update -f etc/test-environment.yml -p $HOME/miniconda && $HOME/miniconda/Scripts/pip install --no-deps . else @@ -101,6 +103,8 @@ jobs: fi - name: py.test shell: bash + env: + CONDA_DEFAULT_CHANNELS: conda-forge run: | if [ $RUNNER_OS == 'Windows' ]; then source $HOME/miniconda/Scripts/activate root && \ From ff548bda40a1ea2dee663e4dbd3db558ccc8e994 Mon Sep 17 00:00:00 2001 From: Albert DeFusco Date: Thu, 25 May 2023 10:48:25 -0500 Subject: [PATCH 09/10] windows doesn't throw errors --- tests/test_archive.py | 7 +++---- tests/test_init.py | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/test_archive.py b/tests/test_archive.py index 231238ef..a2bfa35d 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -152,10 +152,9 @@ def test_archive_output_directory_expanduser(mocker): output_directory = "~__a-conda-project-user__/project" if is_windows(): - with pytest.raises(FileNotFoundError): - _ = CondaProject.from_archive(fn=archive, output_directory=output_directory) + _ = CondaProject.from_archive(fn=archive, output_directory=output_directory) + assert expanduser.call_count == 3 else: with pytest.raises(RuntimeError): _ = CondaProject.from_archive(fn=archive, output_directory=output_directory) - - assert expanduser.call_count == 1 + assert expanduser.call_count == 1 diff --git a/tests/test_init.py b/tests/test_init.py index c7632bf4..5f0ab3c0 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -20,8 +20,7 @@ def test_project_init_expanduser(mocker): project_directory = "~__a-conda-project-user__/project" if is_windows(): - with pytest.raises(FileNotFoundError): - _ = CondaProject(project_directory) + _ = CondaProject(project_directory) else: with pytest.raises(RuntimeError): _ = CondaProject(project_directory) @@ -130,8 +129,7 @@ def test_project_directory_expanduser(mocker): directory = "~__a-conda-project-user__/project" if is_windows(): - with pytest.raises(FileNotFoundError): - _ = CondaProject(directory) + _ = CondaProject(directory) else: with pytest.raises(RuntimeError): _ = CondaProject(directory) From 308180a90c1493fc51df76a48a9f08804ff97bc0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 May 2023 15:49:48 +0000 Subject: [PATCH 10/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_init.py b/tests/test_init.py index 5f0ab3c0..55ea0900 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -20,7 +20,7 @@ def test_project_init_expanduser(mocker): project_directory = "~__a-conda-project-user__/project" if is_windows(): - _ = CondaProject(project_directory) + _ = CondaProject(project_directory) else: with pytest.raises(RuntimeError): _ = CondaProject(project_directory)