def test_merge_error_can_not_merge(): with pytest.raises( ValueError, match='.*because it will override the previous value.*'): merge([{'a': '1'}, {'a': '2'}]) with pytest.raises(ValueError, match='Found.*when a dict is expected.*'): merge([{'a': []}, {'a': {}}])
def test_merge_error_can_not_merge(): with pytest.raises( ValueError, match=".*because it will override the previous value.*"): merge([{"a": "1"}, {"a": "2"}]) with pytest.raises(ValueError, match="Found.*when a dict is expected.*"): merge([{"a": []}, {"a": {}}])
def test_merge_dependencies_with_pip(): a = { "name": "a", "dependencies": ["a_dependency", { "pip": [ "some_from_pip >=0.1", ] }] } b = { "name": "b", "dependencies": ["b_dependency", { "pip": [ "some_from_pip >=0.2", ] }] } merged_dict = merge([a, b]) assert merged_dict == { "dependencies": [ "a_dependency", "b_dependency", { "pip": [ "some_from_pip >=0.1,>=0.2", ] } ] }
def test_merge_empty_dependencies(): """ This happens when an environment file is declared like this: name: foo dependencies: {% if False %} - dependency {% endif %} """ assert merge([ { "name": "a", "dependencies": [] }, { "name": "b", "dependencies": None }, ]) == { "dependencies": [], } assert merge([ { "name": "b", "dependencies": None }, { "name": "a", "dependencies": [] }, ]) == { "dependencies": [], } assert merge([ { "name": "b", "dependencies": None }, { "name": "a", "dependencies": None }, ]) == {}
def test_merge_plain(): a = { "name": "a", "dependencies": [ "a_dependency", ], "environment": { "PATH": [ "a_path", ] } } b = { "name": "b", "dependencies": [ "b_dependency", ], "environment": { "PATH": ["b_path"] }, "channels": [ "b_channel", ], } merged_dict = merge([a, b]) assert merged_dict == { "channels": [ "b_channel", ], "dependencies": [ "a_dependency", "b_dependency", ], "environment": { "PATH": [ "a_path", "b_path", ] } }