1 # Copyright (C) 2003 Python Software Foundation
5 from test
import test_support
7 aetypes
= test_support
.import_module('aetypes')
8 aepack
= test_support
.import_module('aepack')
10 class TestAepack(unittest
.TestCase
):
14 aetypes
.Keyword('kwrd'),
16 aetypes
.Comparison(1, '< ', 10),
17 aetypes
.Logical('not ', 1),
18 aetypes
.IntlText(0, 0, 'international text'),
19 aetypes
.IntlWritingCode(0,0),
20 aetypes
.QDPoint(50,100),
21 aetypes
.QDRectangle(50,100,150,200),
22 aetypes
.RGBColor(0x7000, 0x6000, 0x5000),
23 aetypes
.Unknown('xxxx', 'unknown type data'),
25 aetypes
.Character(2, aetypes
.Line(2)),
28 def test_roundtrip_string(self
):
30 packed
= aepack
.pack(o
)
31 unpacked
= aepack
.unpack(packed
)
32 self
.assertEqual(o
, unpacked
)
34 def test_roundtrip_int(self
):
36 packed
= aepack
.pack(o
)
37 unpacked
= aepack
.unpack(packed
)
38 self
.assertEqual(o
, unpacked
)
40 def test_roundtrip_float(self
):
42 packed
= aepack
.pack(o
)
43 unpacked
= aepack
.unpack(packed
)
44 self
.assertEqual(o
, unpacked
)
46 def test_roundtrip_None(self
):
48 packed
= aepack
.pack(o
)
49 unpacked
= aepack
.unpack(packed
)
50 self
.assertEqual(o
, unpacked
)
52 def test_roundtrip_aeobjects(self
):
53 for o
in self
.OBJECTS
:
54 packed
= aepack
.pack(o
)
55 unpacked
= aepack
.unpack(packed
)
56 self
.assertEqual(repr(o
), repr(unpacked
))
58 def test_roundtrip_FSSpec(self
):
64 if not hasattr(Carbon
.File
, "FSSpec"):
66 o
= Carbon
.File
.FSSpec(os
.curdir
)
67 packed
= aepack
.pack(o
)
68 unpacked
= aepack
.unpack(packed
)
69 self
.assertEqual(o
.as_pathname(), unpacked
.as_pathname())
71 def test_roundtrip_Alias(self
):
76 if not hasattr(Carbon
.File
, "FSSpec"):
78 o
= Carbon
.File
.FSSpec(os
.curdir
).NewAliasMinimal()
79 packed
= aepack
.pack(o
)
80 unpacked
= aepack
.unpack(packed
)
81 self
.assertEqual(o
.FSResolveAlias(None)[0].as_pathname(),
82 unpacked
.FSResolveAlias(None)[0].as_pathname())
86 test_support
.run_unittest(TestAepack
)
89 if __name__
== '__main__':