コード例 #1
0
def test_str_raises_type_error():
    with pytest.raises(CastingFailureException):
        sanitize(TypeErrorString())
コード例 #2
0
def test_str_raises_attribute_error():
    with pytest.raises(CastingFailureException):
        sanitize(AttributeErrorString())
コード例 #3
0
def test_sanitize_tuple():
    t = ('one', 'two', 'three')
    assert sanitize(t) == "('one', 'two', 'three')"
コード例 #4
0
def test_sanitize_object():
    f = Foo()
    assert sanitize(f) == str(f)
コード例 #5
0
def test_sanitize_dict():
    d = {1: 'foo'}
    assert sanitize(d) == "{1: 'foo'}"
コード例 #6
0
def test_sanitize_list():
    l = [1, 2, 3, 4]
    assert sanitize(l) == '[1, 2, 3, 4]'
コード例 #7
0
def test_sanitize_int():
    assert sanitize(9876) == 9876
コード例 #8
0
def test_sanitize_long():
    l = long(123456)
    assert sanitize(l) == l
コード例 #9
0
def test_sanitize_float():
    assert sanitize(1.11) == 1.11
コード例 #10
0
def test_sanitize_bool():
    assert sanitize(True) is True
コード例 #11
0
def test_sanitize_unicode():
    u = u'SMILING FACE: \u263a'
    assert sanitize(u) == u
コード例 #12
0
def test_sanitize_bytes():
    b = b'bytes'
    assert sanitize(b) == b
コード例 #13
0
def test_sanitize_string():
    s = 'foo'
    assert sanitize(s) == s