Esempio n. 1
0
def test_getpop_no_default_raises():
    target: Dict = {"a": {"b": {}}}
    spec: List[str] = ["a", "b", "c"]
    with raises(nesteddicts.MissingDataError):
        nesteddicts.pop(target, spec)
Esempio n. 2
0
def test_getpop_missing_no_delete():
    target: Dict = {"a": {"b": {}}}
    spec: List[str] = ["a", "b", "c"]
    expected: Dict = target.copy()
    nesteddicts.pop(target, spec, default="value")
    assert expected == target
Esempio n. 3
0
def test_getpop_deletes():
    target: Dict = {"a": {"b": {"c": "value"}}}
    spec: List[str] = ["a", "b", "c"]
    nesteddicts.pop(target, spec)
    expected: Dict = {"a": {"b": {}}}
    assert expected == target
Esempio n. 4
0
def test_getpop_missing_returns_default():
    target: Dict = {"a": {"b": {}}}
    spec: List[str] = ["a", "b", "c"]
    expected: str = "value"
    actual: str = nesteddicts.pop(target, spec, default="value")
    assert actual == expected
Esempio n. 5
0
def test_pop_gets_value():
    target: Dict = {"a": {"b": {"c": "value"}}}
    spec: List[str] = ["a", "b", "c"]
    expected: str = "value"
    actual: str = nesteddicts.pop(target, spec)
    assert actual == expected