8000 Fix channel args cli by ericpre · Pull Request #10735 · conda/conda · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Fix channel args cli #10735

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

Merged
merged 3 commits into from
Jun 23, 2021
Merged

Fix channel args cli #10735

merged 3 commits into from
Jun 23, 2021

Conversation

ericpre
Copy link
Contributor
@ericpre ericpre commented Jun 20, 2021

Fix #10732.

@ericpre ericpre requested a review from a team as a code owner June 20, 2021 15:54
@anaconda-issue-bot anaconda-issue-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jun 20, 2021
Comment on lines 345 to 388
def test_channels_defaults(self):
# no channels provided in cli
reset_context(())
assert context.channels == ('defaults', )

def test_channels_defaults_condarc(self):
# no channels provided in cli
reset_context(())
string = dals("""
channels: ['defaults', 'conda-forge']
""")
rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_round_trip_load(string)))
context._set_raw_data(rd)
assert context.channels == ('defaults', 'conda-forge')

def test_specify_channels_cli_adding_defaults_no_condarc(self):
# When the channel haven't been specified in condarc, 'defaults'
# should be present when specifying channel in the cli
reset_context((), argparse_args=AttrDict(channel=['conda-forge']))
assert context.channels == ('conda-forge', 'defaults')

def test_specify_channels_cli_condarc(self):
# When the channel have been specified in condarc, these channels
# should be used along with the one specified
reset_context((), argparse_args=AttrDict(channel=['conda-forge']))
string = dals("""
channels: ['defaults', 'conda-forge']
""")
rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_round_trip_load(string)))
context._set_raw_data(rd)
assert context.channels == ('defaults', 'conda-forge')

def test_specify_different_channels_cli_condarc(self):
# When the channel have been specified in condarc, these channels
# should be used along with the one specified
# In this test, the given channel in cli is different from condarc
# 'defaults' should not be added
reset_context((), argparse_args=AttrDict(channel=['other']))
string = dals("""
channels: ['conda-forge']
""")
rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_round_trip_load(string)))
context._set_raw_data(rd)
assert context.channels == ('conda-forge', 'other')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests check the current behaviour and pass without this PR.

@ericpre
Copy link
Contributor Author
ericpre commented Jun 20, 2021

At first, it was not clear to me when the 'defaults' channel need to be added but based on the conda documentation, I added to tests cover the different cases and it should be good now.

@@ -720,11 +720,23 @@ def channels(self):
if self._argparse_args and 'channel' in self._argparse_args:
8000 Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if block is necessary to cover the case in test_specify_channels_cli_adding_defaults_no_condarc.

Copy link
Member
@jezdez jezdez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me in general, here are just some suggestions around using docstrings in the test functions so the pytest traceback has the full context. Minor fixes around tuple syntax and docstring content as well.

Co-authored-by: Jannis Leidel <jannis@leidel.info>
@ericpre
Copy link
Contributor Author
ericpre commented Jun 23, 2021

Thanks @jezdez for the review, I have applied your suggestions!

Copy link
Member
@jezdez jezdez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ericpre!

@jezdez jezdez merged commit 3df1fb7 into conda:master Jun 23, 2021
FaustinCarter pushed a commit to FaustinCarter/conda that referenced this pull request Nov 27, 2021
* Don't add 'defaults' channels when not necessary

* Add config_files property to Context class to avoid duplicating code

* Apply suggestions from code review: improve docstring and formatting

Co-authored-by: Jannis Leidel <jannis@leidel.info>
@github-actions github-actions bot added the locked [bot] locked due to inactivity label Jun 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed [bot] added once the contributor has signed the CLA locked [bot] locked due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

defaults is added when conda-forge is the only channel and -c is given.
3 participants
0