示例#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([]) == []