-
Notifications
You must be signed in to change notification settings - Fork 5
ARGS: defaults is now always interpreted as a list #29
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e4e1e51
ARGS: defaults str->list, removes xdefaults, adds defaults dict_merge…
62a3983
ACTIONS: add setenv to actions, add tox deps yacclike, fix iterator
8fb9309
TESTS: change defaults in test namespace str->list
97259c5
TESTS: add defaults-release.sh
29ba87a
TESTS: add tests for the dict_merge
6bcfd27
TESTS: add tests for yaml include
886170c
TESTS: remove xdefaults from tests
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import unittest | ||
| import yaml | ||
| import bits_helpers.utilities | ||
| from bits_helpers.utilities import merge_dicts | ||
|
|
||
| class DeepMergeTest(unittest.TestCase): | ||
| # Test overwriting existing top-level keys from dict1 with top-level keys from dict2. | ||
| # Test adding new top level keys from dict2. | ||
| def test_flat_merge(self): | ||
| d1 = ({"a": 1, "b": 2}) | ||
| d2 = ({"b": 3, "c": 4}) | ||
| result = merge_dicts(d1, d2) | ||
| self.assertEqual(result, {"a": 1, "b": 3, "c": 4}) | ||
|
|
||
| # Test nested merge of dicts within dicts | ||
| def test_nested_merge(self): | ||
| d1 = { | ||
| "a": 1, | ||
| "b": {"x": 1, "y": 2}, | ||
| } | ||
| d2 = { | ||
| "b": {"y": 3, "z": 4}, | ||
| "c": 5, | ||
| } | ||
| result = merge_dicts(d1, d2) | ||
| expected = {"a": 1, "b": {"x": 1, "y": 3, "z": 4}, "c": 5} | ||
| self.assertEqual(result, expected) | ||
|
|
||
| # Test merging of lists | ||
| def test_list_merge(self): | ||
| d1 = {"disabled": ["pkg1", "pkg2"]} | ||
| d2 = {"disabled": ["pkg3"]} | ||
| result = merge_dicts(d1, d2) | ||
| self.assertEqual(result, {"disabled": ["pkg1", "pkg2", "pkg3"]}) | ||
|
|
||
| # Test non-recursive overwrite on type mismatch between dict and non-dict | ||
| def test_overwrite_non_dict(self): | ||
| d1 = {"a": {"nested": 1}} | ||
| d2 = {"a": 42} | ||
| result = merge_dicts(d1, d2) | ||
| self.assertEqual(result, {"a": 42}) | ||
|
|
||
| # Test merging of non-overlapping dictionaries | ||
| def test_new_key_added(self): | ||
| d1 = {"a": 1} | ||
| d2 = {"b": 2} | ||
| result = merge_dicts(d1, d2) | ||
| self.assertEqual(result, {"a": 1, "b": 2}) | ||
|
|
||
| # Test merging of empty dictionaries | ||
| def test_empty_dicts(self): | ||
| d1 = {} | ||
| d2 = {} | ||
| result = merge_dicts(d1, d2) | ||
| self.assertEqual(result, {}) | ||
|
|
||
| # Test merging a non-empty first with empty second dict | ||
| def test_merge_with_empty_second(self): | ||
| d1 = {"a": 1} | ||
| d2 = {} | ||
| result = merge_dicts(d1, d2) | ||
| self.assertEqual(result, {"a": 1}) | ||
|
|
||
| # Test merging a empty first with non-empty second dict | ||
| def test_merge_with_empty_first(self): | ||
| d1 = {} | ||
| d2 = {"b": 2} | ||
| result = merge_dicts(d1, d2) | ||
| self.assertEqual(result, {"b": 2}) | ||
|
|
||
| # Test type mismatch between list and non-list | ||
| def test_list_non_list_conflict(self): | ||
| """When one side is list and the other is not, prefer dict2.""" | ||
| d1 = {"disabled": ["pkg1", "pkg2"]} | ||
| d2 = {"disabled": "notalist"} | ||
| result = merge_dicts(d1, d2) | ||
| self.assertEqual(result, {"disabled": "notalist"}) |
Oops, something went wrong.
Oops, something went wrong.
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.
Also here: not clear what the point of (e.g.)
defaults-lcg in specsis, since this is not going to have all the defaults in specs eventually.I guess more of a question for @pbuncic.