Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_key2value():
sources = ("a", "b", "d", "hello")
sources_duplicate = ("a", "b", "d", "hello", "b")
dests = (54, "e", 2)
dests_duplicate = (54, "e", 2, "e")
source2dest = {"b": 55, "hello": "world"}
source2dest_with_extra_key = {"b": 55, "hello": "world", "toto": 4}
expected_result = (("a", "d"), (54, "e", 2, 55, "world"), {1: 3, 3: 4})
with pytest.raises(ValueError):
inliner.key2value(sources_duplicate, dests, source2dest)
with pytest.raises(ValueError):
inliner.key2value(sources, dests_duplicate, source2dest)
with pytest.raises(ValueError):
inliner.key2value(sources, dests, source2dest_with_extra_key)
assert inliner.key2value(sources, dests, source2dest) == expected_result
sources = ("a", "b", "d", "hello")
sources_duplicate = ("a", "b", "d", "hello", "b")
dests = (54, "e", 2)
dests_duplicate = (54, "e", 2, "e")
source2dest = {"b": 55, "hello": "world"}
source2dest_with_extra_key = {"b": 55, "hello": "world", "toto": 4}
expected_result = (("a", "d"), (54, "e", 2, 55, "world"), {1: 3, 3: 4})
with pytest.raises(ValueError):
inliner.key2value(sources_duplicate, dests, source2dest)
with pytest.raises(ValueError):
inliner.key2value(sources, dests_duplicate, source2dest)
with pytest.raises(ValueError):
inliner.key2value(sources, dests, source2dest_with_extra_key)
assert inliner.key2value(sources, dests, source2dest) == expected_result
dests = (54, "e", 2)
dests_duplicate = (54, "e", 2, "e")
source2dest = {"b": 55, "hello": "world"}
source2dest_with_extra_key = {"b": 55, "hello": "world", "toto": 4}
expected_result = (("a", "d"), (54, "e", 2, 55, "world"), {1: 3, 3: 4})
with pytest.raises(ValueError):
inliner.key2value(sources_duplicate, dests, source2dest)
with pytest.raises(ValueError):
inliner.key2value(sources, dests_duplicate, source2dest)
with pytest.raises(ValueError):
inliner.key2value(sources, dests, source2dest_with_extra_key)
assert inliner.key2value(sources, dests, source2dest) == expected_result
source2dest = {"b": 55, "hello": "world"}
source2dest_with_extra_key = {"b": 55, "hello": "world", "toto": 4}
expected_result = (("a", "d"), (54, "e", 2, 55, "world"), {1: 3, 3: 4})
with pytest.raises(ValueError):
inliner.key2value(sources_duplicate, dests, source2dest)
with pytest.raises(ValueError):
inliner.key2value(sources, dests_duplicate, source2dest)
with pytest.raises(ValueError):
inliner.key2value(sources, dests, source2dest_with_extra_key)
assert inliner.key2value(sources, dests, source2dest) == expected_result