Example #1
0
def test_exact_get():
    m = Map()
    a = MapKey('a')
    b = MapKey('b', parents=[a])
    
    m[a] = u"Value for A"

    assert m.exact_get(b) is None
    assert m.exact_get(b, u'default') == u'default'
    assert m.exact_get(a) == u'Value for A'
Example #2
0
def test_exact_getitem():
    m = Map()
    a = MapKey('a')
    b = MapKey('b', parents=[a])
    
    m[a] = u"Value for A"

    with py.test.raises(KeyError):
        m.exact_getitem(b)
    assert m.exact_getitem(a) == u'Value for A'
Example #3
0
def test_map_all():
    m = Map()
    a = MapKey('a')
    b = MapKey('b', parents=[a])
    c = MapKey('c', parents=[a])
    d = MapKey('d', parents=[b, c])

    m[b] = u'Value for B'
    m[c] = u'Value for C'
    m[d] = u'Value for D'
    assert m.all(d) == [u'Value for D', u'Value for B', u'Value for C']