def test_getpop_no_default_raises(): target: Dict = {"a": {"b": {}}} spec: List[str] = ["a", "b", "c"] with raises(nesteddicts.MissingDataError): nesteddicts.pop(target, spec)
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
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
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
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