Exemplo n.º 1
0
def test_lambda_conflator_str_dirty():
    c = conflateddict.LambdaConflator(lambda x, y: x + sum(y))
    for i in range(random.randint(1, 10)):
        c[i] = 1
    expected_str = '<LambdaConflator dirty:{dirty} entries:{entries}>'.format(
        dirty=i + 1, entries=i + 1)
    assert str(c) == expected_str
Exemplo n.º 2
0
def test_lambda_conflator_default_args():
    lc = conflateddict.LambdaConflator()
    dc = conflateddict.ConflatedDict()

    for i in range(10):
        key = i % 3
        lc[key] = i
        dc[key] = i
        assert lc[key] == dc[key]
Exemplo n.º 3
0
def test_lambda_conflator():
    c = conflateddict.LambdaConflator(lambda x, y: x + sum(y))
    c[1] = 1
    assert c[1] == 1
    c[1] = 2
    assert c[1] == 3
    c[1] = 3
    assert c[1] == 6
    c.reset()
    c[1] = 1
    assert c[1] == 1
Exemplo n.º 4
0
def test_lambda_conflator_name():
    n = 'MyName'
    c = conflateddict.LambdaConflator(lambda x, y: x + sum(y), n)
    assert str(c) == '<{} dirty:{} entries:{}>'.format(n, 0, 0)
Exemplo n.º 5
0
def test_lambda_conflator_str_clean():
    c = conflateddict.LambdaConflator(lambda x, y: x + sum(y))
    assert str(c) == '<LambdaConflator dirty:0 entries:0>'