annotate Lib/test/test_aepack.py @ 54294:dba767bc3155 legacy-trunk

remove mention of old ctypes version
author Benjamin Peterson <benjamin@python.org>
date Sat, 23 May 2009 20:59:09 +0000
parents f2c90fd05d66
children 34496bed9365
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27516
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 # Copyright (C) 2003 Python Software Foundation
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
2
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3 import unittest
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4 import os
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5 from test import test_support
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6
52456
f2c90fd05d66 Add import_function method to test.test_support, and modify a number of
R. David Murray <rdmurray@bitdance.com>
parents: 27963
diff changeset
7 aetypes = test_support.import_module('aetypes')
f2c90fd05d66 Add import_function method to test.test_support, and modify a number of
R. David Murray <rdmurray@bitdance.com>
parents: 27963
diff changeset
8 aepack = test_support.import_module('aepack')
f2c90fd05d66 Add import_function method to test.test_support, and modify a number of
R. David Murray <rdmurray@bitdance.com>
parents: 27963
diff changeset
9
27516
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
10 class TestAepack(unittest.TestCase):
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
11 OBJECTS = [
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
12 aetypes.Enum('enum'),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
13 aetypes.Type('type'),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
14 aetypes.Keyword('kwrd'),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
15 aetypes.Range(1, 10),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
16 aetypes.Comparison(1, '< ', 10),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
17 aetypes.Logical('not ', 1),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
18 aetypes.IntlText(0, 0, 'international text'),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
19 aetypes.IntlWritingCode(0,0),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
20 aetypes.QDPoint(50,100),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
21 aetypes.QDRectangle(50,100,150,200),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
22 aetypes.RGBColor(0x7000, 0x6000, 0x5000),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
23 aetypes.Unknown('xxxx', 'unknown type data'),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
24 aetypes.Character(1),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25 aetypes.Character(2, aetypes.Line(2)),
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 ]
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
27
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
28 def test_roundtrip_string(self):
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
29 o = 'a string'
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
30 packed = aepack.pack(o)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
31 unpacked = aepack.unpack(packed)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
32 self.assertEqual(o, unpacked)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
33
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
34 def test_roundtrip_int(self):
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
35 o = 12
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
36 packed = aepack.pack(o)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
37 unpacked = aepack.unpack(packed)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
38 self.assertEqual(o, unpacked)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
39
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
40 def test_roundtrip_float(self):
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
41 o = 12.1
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
42 packed = aepack.pack(o)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
43 unpacked = aepack.unpack(packed)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
44 self.assertEqual(o, unpacked)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
45
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
46 def test_roundtrip_None(self):
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
47 o = None
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
48 packed = aepack.pack(o)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
49 unpacked = aepack.unpack(packed)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
50 self.assertEqual(o, unpacked)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
51
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
52 def test_roundtrip_aeobjects(self):
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
53 for o in self.OBJECTS:
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
54 packed = aepack.pack(o)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
55 unpacked = aepack.unpack(packed)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
56 self.assertEqual(repr(o), repr(unpacked))
27963
226463445697 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 27516
diff changeset
57
27516
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
58 def test_roundtrip_FSSpec(self):
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
59 try:
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
60 import Carbon.File
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
61 except:
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
62 return
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
63 o = Carbon.File.FSSpec(os.curdir)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
64 packed = aepack.pack(o)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
65 unpacked = aepack.unpack(packed)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
66 self.assertEqual(o.as_pathname(), unpacked.as_pathname())
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
67
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
68 def test_roundtrip_Alias(self):
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
69 try:
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
70 import Carbon.File
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
71 except:
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
72 return
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
73 o = Carbon.File.FSSpec(os.curdir).NewAliasMinimal()
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
74 packed = aepack.pack(o)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
75 unpacked = aepack.unpack(packed)
27963
226463445697 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 27516
diff changeset
76 self.assertEqual(o.FSResolveAlias(None)[0].as_pathname(),
27516
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
77 unpacked.FSResolveAlias(None)[0].as_pathname())
27963
226463445697 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 27516
diff changeset
78
27516
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
79
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
80 def test_main():
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
81 test_support.run_unittest(TestAepack)
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
82
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
83
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
84 if __name__ == '__main__':
5f32942a225a Moved aepack test code to the test suite.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
85 test_main()