示例#1
0
def test_get_by_seq_finds():
    tr = Trict(base_dict())
    old_data = copy.deepcopy(tr.data)
    val = tr.get_by_seq([
        'user.misinformation.attribute', 'nonuser.noninformation.nonattribute',
        ['user', 'information', 'attribute']
    ])
    assert val == 'infonugget'
    assert tr.data == old_data
    val = tr.get_by_seq([['user', 'information', 'whatattribute'],
                         ['user', 'information', 'nonattribute'],
                         'user.information.another_attribute'])
    assert val == 'secondnugget'
    assert tr.data == old_data
示例#2
0
def test_nonstrict_get_by_seq_not_throws():
    tr = Trict(base_dict())
    val = tr.get_by_seq(['none.of.these', 'i.mean.none', ['keys', 'exist']])
    assert val == None
示例#3
0
def test_strict_get_by_seq_throws():
    tr = Trict(base_dict())
    with pytest.raises(KeyError):
        tr.get_by_seq(['none.of.these', 'i.mean.none', ['keys', 'exist']],
                      strict=True)