コード例 #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
ファイル: test_pycompat.py プロジェクト: UW-Hydro/RVIC
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
ファイル: test_pycompat.py プロジェクト: yuanyao0804/RVIC
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
ファイル: test_pycompat.py プロジェクト: yuanyao0804/RVIC
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
ファイル: test_pycompat.py プロジェクト: UW-Hydro/RVIC
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
ファイル: test_pycompat.py プロジェクト: yuanyao0804/RVIC
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
ファイル: test_pycompat.py プロジェクト: yuanyao0804/RVIC
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
ファイル: test_pycompat.py プロジェクト: yuanyao0804/RVIC
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