示例#1
0
def test_update_with_insert():
    d = OrderedDict([('a', 'b'),
               ('c', 'd'),
               ('e', 'f'),
               ('g', 'h')])

    d.insert('c', 'z', 3)

    assert_against_list(d, [('a', 'b'),
                            ('e', 'f'),
                            ('g', 'h'),
                            ('c', 'z')])
示例#2
0
def test_insert():
    scenario = [(('a', 'b', 2), 0), (('c', 'd', 2), 1), (('e', 'f', 2), 2),
                (('g', 'h', 2), 2), (('i', 'j', 2), 2), (('k', 'l', 10), 5),
                (('m', 'n', 4), 4)]

    d = OrderedDict()
    for data, result in scenario:
        d.insert(*data)
        assert d[data[0]] == data[1]
        assert d.keys()[result] == data[0]

    assert_against_list(d, [('a', 'b'), ('c', 'd'), ('i', 'j'), ('g', 'h'),
                            ('m', 'n'), ('e', 'f'), ('k', 'l')])
示例#3
0
def test_insert():
    scenario = [(('a', 'b', 2), 0),
                (('c', 'd', 2), 1),
                (('e', 'f', 2), 2),
                (('g', 'h', 2), 2),
                (('i', 'j', 2), 2),
                (('k', 'l', 10), 5),
                (('m', 'n', 4), 4)]

    d = OrderedDict()
    for data, result in scenario:
        d.insert(*data)
        assert d[data[0]] == data[1]
        assert d.keys()[result] == data[0]

    assert_against_list(d, [('a', 'b'),
                            ('c', 'd'),
                            ('i', 'j'),
                            ('g', 'h'),
                            ('m', 'n'),
                            ('e', 'f'),
                            ('k', 'l')])
示例#4
0
def test_update_with_insert():
    d = OrderedDict([('a', 'b'), ('c', 'd'), ('e', 'f'), ('g', 'h')])

    d.insert('c', 'z', 3)

    assert_against_list(d, [('a', 'b'), ('e', 'f'), ('g', 'h'), ('c', 'z')])