-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Export 'channels'
as part of environments' export
#3587
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5e1f3c1
Always print 'channels' during `env export`
mathbunnyru 29a13a6
Merge branch 'main' into export_empty_env
mathbunnyru 7670c2a
Update test_env.py
mathbunnyru c480e0f
Merge branch 'main' into export_empty_env
mathbunnyru 8a583b9
Merge branch 'main' into export_empty_env
mathbunnyru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,31 +70,47 @@ def export_env(): | |
return env_name | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def empty_env(): | ||
env_name = "env-empty" | ||
helpers.create("-n", env_name) | ||
return env_name | ||
|
||
|
||
@pytest.mark.parametrize("json_flag", [None, "--json"]) | ||
def test_empty_env_export(json_flag, empty_env): | ||
flags = filter(None, [json_flag]) | ||
output = helpers.run_env("export", "-n", empty_env, *flags) | ||
|
||
# json is already parsed | ||
ret = output if json_flag else yaml.safe_load(output) | ||
assert ret["name"] == empty_env | ||
assert "env-empty" in ret["prefix"] | ||
assert not ret["channels"] | ||
|
||
|
||
@pytest.mark.parametrize("channel_subdir_flag", [None, "--channel-subdir"]) | ||
@pytest.mark.parametrize("md5_flag", [None, "--md5", "--no-md5"]) | ||
@pytest.mark.parametrize("explicit_flag", [None, "--explicit"]) | ||
@pytest.mark.parametrize("no_build_flag", [None, "--no-build", "--no-builds"]) | ||
@pytest.mark.parametrize("json_flag", [None, "--json"]) | ||
def test_env_export( | ||
export_env, json_flag, no_build_flag, explicit_flag, md5_flag, channel_subdir_flag | ||
channel_subdir_flag, md5_flag, explicit_flag, no_build_flag, json_flag, export_env | ||
): | ||
if explicit_flag and json_flag: | ||
# `--explicit` has precedence over `--json`, which is tested bellow. | ||
# But we need to omit here to avoid `helpers.run_env` to parse the output as JSON and fail. | ||
json_flag = None | ||
|
||
flags = filter(None, [no_build_flag, json_flag, explicit_flag, md5_flag, channel_subdir_flag]) | ||
flags = filter(None, [channel_subdir_flag, md5_flag, explicit_flag, no_build_flag, json_flag]) | ||
output = helpers.run_env("export", "-n", export_env, *flags) | ||
if explicit_flag: | ||
assert "/micromamba-0.24.0-0." in output | ||
if md5_flag != "--no-md5": | ||
assert re.search("#[a-f0-9]{32}$", output.replace("\r", "")) | ||
else: | ||
if json_flag: | ||
# Already parsed | ||
ret = output | ||
else: | ||
ret = yaml.safe_load(output) | ||
# json is already parsed | ||
ret = output if json_flag else yaml.safe_load(output) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is quite easy to read as a one-line |
||
assert ret["name"] == export_env | ||
assert "env-create-export" in ret["prefix"] | ||
assert set(ret["channels"]) == {"conda-forge"} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the order it is mentioned above, it's better to have the same order everywhere