def test_raises_for_builtins(cls): obj = cls() with pytest.raises(TypeError): resolve_obj(obj, ['__class__'])
def test_object_with_none_is_treated_as_a_regular_default_value(obj): r = resolve_obj(obj, ['abc', 'dez', 'xyz'], None) assert r is None
def test_object_with_empty_path(obj): r = resolve_obj(obj, []) assert r == obj assert r is obj
def test_object_with_nonmapping_with_default(obj): r = resolve_obj(obj, ['key', 'sub'], default) assert r is default
def test_object_with_nonmapping_with_no_default(obj): with pytest.raises(TypeError): resolve_obj(obj, ['key', 'sub'])
def test_object_with_inexistent_key_with_default(obj, key): r = resolve_obj(obj, key, default) assert r is default
def test_object_with_inexistent_key_with_no_default(obj, key): with pytest.raises(AttributeError): resolve_obj(obj, key)
def test_object_with_existent_key_with_default(obj): r = resolve_obj(obj, ['abc', 'dez', 'hij'], default) assert r == 'val'