示例#1
0
def test_ordered_dict_append():
    a = [1, 2, 3]
    b = ["a", "b", "c"]
    d = OrderedDict(pyzip(a, b))
    d[4] = "d"
    assert len(d) == 4
    assert list(d.keys())[-1] == 4
示例#2
0
def test_itervalues_ordered_dict():
    a = [1, 2, 3]
    b = ["a", "b", "c"]
    d = OrderedDict(pyzip(a, b))
    for i, v in enumerate(itervalues(d)):
        assert v in b
        assert b[i] == v
示例#3
0
def test_itervalues_ordered_dict():
    a = [1, 2, 3]
    b = ['a', 'b', 'c']
    d = OrderedDict(pyzip(a, b))
    for i, v in enumerate(itervalues(d)):
        assert v in b
        assert b[i] == v
示例#4
0
def test_ordered_dict_append():
    a = [1, 2, 3]
    b = ['a', 'b', 'c']
    d = OrderedDict(pyzip(a, b))
    d[4] = 'd'
    assert len(d) == 4
    assert list(d.keys())[-1] == 4
示例#5
0
def test_iteritems():
    a = [1, 2, 3]
    b = ["a", "b", "c"]
    d = dict(pyzip(a, b))
    for k, v in iteritems(d):
        assert k in a
        assert v in b
        assert d[k] == v
示例#6
0
def test_iteritems():
    a = [1, 2, 3]
    b = ['a', 'b', 'c']
    d = dict(pyzip(a, b))
    for k, v in iteritems(d):
        assert k in a
        assert v in b
        assert d[k] == v
示例#7
0
def test_iteritems_ordered_dict():
    a = [1, 2, 3]
    b = ["a", "b", "c"]
    d = OrderedDict(pyzip(a, b))
    for i, (k, v) in enumerate(iteritems(d)):
        assert k in a
        assert v in b
        assert d[k] == v
        assert b[i] == v
示例#8
0
def test_iteritems_ordered_dict():
    a = [1, 2, 3]
    b = ['a', 'b', 'c']
    d = OrderedDict(pyzip(a, b))
    for i, (k, v) in enumerate(iteritems(d)):
        assert k in a
        assert v in b
        assert d[k] == v
        assert b[i] == v
示例#9
0
def test_pyzip():
    a = [1, 2, 3]
    b = ["a", "b", "c"]
    x = pyzip(a, b)
    assert hasattr(x, "__iter__")
    for i, (aa, bb) in enumerate(x):
        assert aa == a[i]
        assert bb == b[i]
    with pytest.raises(TypeError):
        len(x)
        x[1]
示例#10
0
def test_pyzip():
    a = [1, 2, 3]
    b = ['a', 'b', 'c']
    x = pyzip(a, b)
    assert hasattr(x, '__iter__')
    for i, (aa, bb) in enumerate(x):
        assert aa == a[i]
        assert bb == b[i]
    with pytest.raises(TypeError):
        len(x)
        x[1]
示例#11
0
def test_ordered_dict_order():
    a = [1, 2, 3]
    b = ["a", "b", "c"]
    d = OrderedDict(pyzip(a, b))
    assert list(d.keys()) == a
    assert list(d.values()) == b
示例#12
0
def test_itervalues():
    a = [1, 2, 3]
    b = ["a", "b", "c"]
    d = dict(pyzip(a, b))
    for v in itervalues(d):
        assert v in b
示例#13
0
def test_ordered_dict_order():
    a = [1, 2, 3]
    b = ['a', 'b', 'c']
    d = OrderedDict(pyzip(a, b))
    assert list(d.keys()) == a
    assert list(d.values()) == b
示例#14
0
def test_itervalues():
    a = [1, 2, 3]
    b = ['a', 'b', 'c']
    d = dict(pyzip(a, b))
    for v in itervalues(d):
        assert v in b