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