def test_flatten_lists_and_tuples_to_array(): # simple list of primitives f = plistbin.flatten([10, 11, 12]) assert_equals('[Array, ObjRef, ObjRef, ObjRef, Integer, Integer, Integer]', repr(f)) # list with non-primitive values f = plistbin.flatten([(1,), (4,)]) assert_equals('[Array, ObjRef, ObjRef, Array, ObjRef, Integer, Array, ObjRef, Integer]', repr(f))
def test_flatten_number_objects(): # an int.. f = plistbin.flatten(42) assert_equals('[Integer]', repr(f)) # .. and a float f = plistbin.flatten(42.0005) assert_equals('[Real]', repr(f))
def test_flatten_dicts_to_keyrefs_and_objrefs(): f = plistbin.flatten(dict(one=1,two=2)) assert_equals('[Dict, KeyRef, ObjRef, KeyRef, ObjRef, AsciiString, Integer, AsciiString, Integer]', repr(f))
def test_flatten_datetime_objects(): import datetime f = plistbin.flatten(datetime.datetime.now()) assert_equals('[Date]', repr(f))
def test_flatten_data_objects(): f = plistbin.flatten(plistbin.Data('Some data')) assert_equals('[Data]', repr(f))
def test_unicode_string(): f = plistbin.flatten(u'Æøå') assert_equals('[UnicodeString]', repr(f))
def test_bytecode_string(): f = plistbin.flatten('True') assert_equals('[AsciiString]', repr(f)) assert_equals('True', f[0].value)
def test_flatten_boolean(): f = plistbin.flatten(True) assert_equals('[Boolean]', repr(f)) assert_equals(True, f[0].value)