~malept/ubuntu/lucid/python2.6/dev-dependency-fix

« back to all changes in this revision

Viewing changes to Lib/test/test_aepack.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-13 12:51:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090213125100-uufgcb9yeqzujpqw
Tags: upstream-2.6.1
ImportĀ upstreamĀ versionĀ 2.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2003 Python Software Foundation
 
2
 
 
3
import unittest
 
4
import aepack
 
5
import aetypes
 
6
import os
 
7
from test import test_support
 
8
 
 
9
class TestAepack(unittest.TestCase):
 
10
    OBJECTS = [
 
11
        aetypes.Enum('enum'),
 
12
        aetypes.Type('type'),
 
13
        aetypes.Keyword('kwrd'),
 
14
        aetypes.Range(1, 10),
 
15
        aetypes.Comparison(1, '<   ', 10),
 
16
        aetypes.Logical('not ', 1),
 
17
        aetypes.IntlText(0, 0, 'international text'),
 
18
        aetypes.IntlWritingCode(0,0),
 
19
        aetypes.QDPoint(50,100),
 
20
        aetypes.QDRectangle(50,100,150,200),
 
21
        aetypes.RGBColor(0x7000, 0x6000, 0x5000),
 
22
        aetypes.Unknown('xxxx', 'unknown type data'),
 
23
        aetypes.Character(1),
 
24
        aetypes.Character(2, aetypes.Line(2)),
 
25
    ]
 
26
 
 
27
    def test_roundtrip_string(self):
 
28
        o = 'a string'
 
29
        packed = aepack.pack(o)
 
30
        unpacked = aepack.unpack(packed)
 
31
        self.assertEqual(o, unpacked)
 
32
 
 
33
    def test_roundtrip_int(self):
 
34
        o = 12
 
35
        packed = aepack.pack(o)
 
36
        unpacked = aepack.unpack(packed)
 
37
        self.assertEqual(o, unpacked)
 
38
 
 
39
    def test_roundtrip_float(self):
 
40
        o = 12.1
 
41
        packed = aepack.pack(o)
 
42
        unpacked = aepack.unpack(packed)
 
43
        self.assertEqual(o, unpacked)
 
44
 
 
45
    def test_roundtrip_None(self):
 
46
        o = None
 
47
        packed = aepack.pack(o)
 
48
        unpacked = aepack.unpack(packed)
 
49
        self.assertEqual(o, unpacked)
 
50
 
 
51
    def test_roundtrip_aeobjects(self):
 
52
        for o in self.OBJECTS:
 
53
            packed = aepack.pack(o)
 
54
            unpacked = aepack.unpack(packed)
 
55
            self.assertEqual(repr(o), repr(unpacked))
 
56
 
 
57
    def test_roundtrip_FSSpec(self):
 
58
        try:
 
59
            import Carbon.File
 
60
        except:
 
61
            return
 
62
        o = Carbon.File.FSSpec(os.curdir)
 
63
        packed = aepack.pack(o)
 
64
        unpacked = aepack.unpack(packed)
 
65
        self.assertEqual(o.as_pathname(), unpacked.as_pathname())
 
66
 
 
67
    def test_roundtrip_Alias(self):
 
68
        try:
 
69
            import Carbon.File
 
70
        except:
 
71
            return
 
72
        o = Carbon.File.FSSpec(os.curdir).NewAliasMinimal()
 
73
        packed = aepack.pack(o)
 
74
        unpacked = aepack.unpack(packed)
 
75
        self.assertEqual(o.FSResolveAlias(None)[0].as_pathname(),
 
76
            unpacked.FSResolveAlias(None)[0].as_pathname())
 
77
 
 
78
 
 
79
def test_main():
 
80
    test_support.run_unittest(TestAepack)
 
81
 
 
82
 
 
83
if __name__ == '__main__':
 
84
    test_main()