Skip to content

test_dict_deep_update

Tests of the deep_update() function

Functions:

test_add_top_level_keys

test_add_top_level_keys()
Source code in tests/collections/test_dict_deep_update.py
19
20
def test_add_top_level_keys():
    assert deep_update({"a": 1}, {"b": 2, "c": 3}) == {"a": 1, "b": 2, "c": 3}

test_empty_dict

test_empty_dict()
Source code in tests/collections/test_dict_deep_update.py
6
7
8
9
def test_empty_dict():
    assert deep_update({}, {}) == {}
    assert deep_update({"a": 1}, {}) == {"a": 1}
    assert deep_update({}, {"a": 1}) == {"a": 1}

test_inplace_update

test_inplace_update()
Source code in tests/collections/test_dict_deep_update.py
33
34
35
36
def test_inplace_update():
    t = {"a": {"k": 1}}
    deep_update(t, {"a": {"k": 2, "l": 0}})
    assert t == {"a": {"k": 2, "l": 0}}

test_replace_nested_keys

test_replace_nested_keys()
Source code in tests/collections/test_dict_deep_update.py
23
24
25
26
27
28
29
30
def test_replace_nested_keys():
    assert deep_update({"a": {"k": 1}}, {"a": {"k": 2}}) == {"a": {"k": 2}}
    assert deep_update({"a": {"k": 1, "l": 0}}, {"a": {"k": 2}}) == {
        "a": {"k": 2, "l": 0}
    }
    assert deep_update({"a": {"k": 1}}, {"a": {"k": 2, "l": 0}}) == {
        "a": {"k": 2, "l": 0}
    }

test_replace_top_level_keys

test_replace_top_level_keys()
Source code in tests/collections/test_dict_deep_update.py
12
13
14
15
16
def test_replace_top_level_keys():
    assert deep_update({"a": 1}, {"a": 1}) == {"a": 1}
    assert deep_update({"a": 1}, {"a": 113}) == {"a": 113}
    assert deep_update({"a": {}}, {"a": 113}) == {"a": 113}
    assert deep_update({"a": 1}, {"a": {}}) == {"a": {}}