示例#1
0
def test_raises_for_builtins(cls):
    obj = cls()
    with pytest.raises(TypeError):
        resolve_obj(obj, ['__class__'])
示例#2
0
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
示例#3
0
def test_object_with_empty_path(obj):
    r = resolve_obj(obj, [])
    assert r == obj
    assert r is obj
示例#4
0
def test_object_with_nonmapping_with_default(obj):
    r = resolve_obj(obj, ['key', 'sub'], default)
    assert r is default
示例#5
0
def test_object_with_nonmapping_with_no_default(obj):
    with pytest.raises(TypeError):
        resolve_obj(obj, ['key', 'sub'])
示例#6
0
def test_object_with_inexistent_key_with_default(obj, key):
    r = resolve_obj(obj, key, default)
    assert r is default
示例#7
0
def test_object_with_inexistent_key_with_no_default(obj, key):
    with pytest.raises(AttributeError):
        resolve_obj(obj, key)
示例#8
0
def test_object_with_existent_key_with_default(obj):
    r = resolve_obj(obj, ['abc', 'dez', 'hij'], default)
    assert r == 'val'