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