예제 #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([]) == []