Пример #1
0
def test_object():
    class Object(object):
        pass

    with pytest.raises(exc.ConvertationError):
        converters.array(Object())
Пример #2
0
def test_none():
    with pytest.raises(exc.ConvertationError):
        converters.array(None)
Пример #3
0
def test_generator():
    assert converters.array((x for x in xrange(5))) == [0, 1, 2, 3, 4]
Пример #4
0
def test_list_comprehention():
    assert converters.array([x for x in xrange(5)]) == [0, 1, 2, 3, 4]
Пример #5
0
def test_full_unicode():
    assert converters.array(u'0') == [u'0']
Пример #6
0
def test_int():
    with pytest.raises(exc.ConvertationError):
        converters.array(0)
Пример #7
0
def test_full_dict():
    with pytest.raises(exc.ConvertationError):
        converters.array({0: '0', 1: '1'})
Пример #8
0
def test_full_str():
    assert converters.array('0') == ['0']
Пример #9
0
def test_full_list():
    assert converters.array([0, 1, '0', '1', [],
                             {}]) == [0, 1, '0', '1', [], {}]
Пример #10
0
def test_full_tuple():
    assert converters.array(
        (0, 1, '0', '1', [], {})) == [0, 1, '0', '1', [], {}]
Пример #11
0
def test_empty_unicode():
    assert converters.array(u'') == []
Пример #12
0
def test_empty_str():
    assert converters.array('') == []
Пример #13
0
def test_empty_dict():
    with pytest.raises(exc.ConvertationError):
        converters.array({})
Пример #14
0
def test_empty_tuple():
    assert converters.array(()) == []
Пример #15
0
def test_empty_list():
    assert converters.array([]) == []