Skip to content

Commit

Permalink
Satisfy code formatting hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
danpetry committed Oct 20, 2023
1 parent b4e032e commit 0837ea7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion conda_build/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def filter_combined_spec_to_used_keys(combined_spec, specs):

# TODO: act here?
combined_spec = explode_variants(combined_spec)
seen_keys=set() # seen_keys makes sure that a setting from a lower-priority spec doesn't clobber the same setting that has been redefined in a higher-priority spec.
seen_keys = set() # seen_keys makes sure that a setting from a lower-priority spec doesn't clobber the same setting that has been redefined in a higher-priority spec.
# The specs are checked from high to low priority order.
for source, source_specs in reversed(specs.items()):
for k, vs in source_specs.items():
Expand Down
47 changes: 28 additions & 19 deletions tests/test_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
from conda_build.variants import (
combine_specs,
dict_of_lists_to_list_of_dicts,
filter_combined_spec_to_used_keys,
get_package_variants,
validate_spec,
filter_combined_spec_to_used_keys,
)

from .utils import variants_dir
Expand Down Expand Up @@ -659,35 +659,44 @@ def test_variant_subkeys_retained():
outputs = m.get_output_metadata_set(permit_unsatisfiable_variants=False)
get_all_replacements(outputs[0][1].config.variant)


@pytest.mark.parametrize(
"internal_defaults, low_prio_config, high_prio_config, expected",
[
(
{'pkg_1': '1.0'},
{'pkg_1': '1.1'},
{'pkg_1': ['1.1', '1.2'],
'pkg_2': ['1.1']},
[{'pkg_1': '1.1', 'pkg_2': '1.1'},
{'pkg_1': '1.2', 'pkg_2': '1.1'}]
{"pkg_1": "1.0"},
{"pkg_1": "1.1"},
{"pkg_1": ["1.1", "1.2"],"pkg_2": ["1.1"]},
[{"pkg_1": "1.1", "pkg_2": "1.1"},{"pkg_1": "1.2", "pkg_2": "1.1"}],
),
(
{'pkg_1': '1.0'},
{'pkg_1': '1.1'},
{'pkg_1': ['1.1', '1.2'],
'pkg_2': ['1.1', '1.2'],
'zip_keys': [['pkg_1', 'pkg_2']]},
[{'pkg_1': '1.1', 'pkg_2': '1.1', 'zip_keys': [['pkg_1', 'pkg_2']]},
{'pkg_1': '1.2', 'pkg_2': '1.2', 'zip_keys': [['pkg_1', 'pkg_2']]}]
{"pkg_1": "1.0"},
{"pkg_1": "1.1"},
{
"pkg_1": ["1.1", "1.2"],
"pkg_2": ["1.1", "1.2"],
"zip_keys": [["pkg_1", "pkg_2"]],
},
[
{"pkg_1": "1.1", "pkg_2": "1.1", "zip_keys": [["pkg_1", "pkg_2"]]},
{"pkg_1": "1.2", "pkg_2": "1.2", "zip_keys": [["pkg_1", "pkg_2"]]},
]
)
]
)
def test_zip_key_filtering(internal_defaults, low_prio_config, high_prio_config, expected):
def test_zip_key_filtering(
internal_defaults, low_prio_config, high_prio_config, expected
):
from collections import OrderedDict

combined_spec = low_prio_config.copy()
combined_spec.update(high_prio_config)
specs = OrderedDict([('internal_defaults',internal_defaults),
('low_prio_config',low_prio_config),
('high_prio_config',high_prio_config)])
specs = OrderedDict(
[
('internal_defaults',internal_defaults),
('low_prio_config',low_prio_config),
('high_prio_config',high_prio_config)
]
)

assert filter_combined_spec_to_used_keys(combined_spec, specs=specs) == expected

0 comments on commit 0837ea7

Please sign in to comment.