testArrays.py :  » Windows » pyExcelerator » pywin32-214 » com » win32com » test » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Windows » pyExcelerator 
pyExcelerator » pywin32 214 » com » win32com » test » testArrays.py
# Originally contributed by Stefan Schukat as part of this arbitrary-sized
# arrays patch.
from win32com.client import gencache
from win32com.test import util
import unittest

ZeroD = 0
OneDEmpty = []
OneD  = [1,2,3]
TwoD = [
        [1,2,3],
        [1,2,3],
        [1,2,3]
       ]

TwoD1 = [
          [
            [1,2,3,5],
            [1,2,3],
            [1,2,3]
          ],
          [
            [1,2,3],
            [1,2,3],
            [1,2,3]
          ]
       ]

OneD1 = [
          [
            [1,2,3],
            [1,2,3],
            [1,2,3]
          ],
          [
             [1,2,3],
             [1,2,3]
          ]
         ]

OneD2 = [
          [1,2,3],
          [1,2,3,4,5],
          [
             [1,2,3,4,5],
             [1,2,3,4,5],
             [1,2,3,4,5]
          ]
         ]


ThreeD = [
          [
            [1,2,3],
            [1,2,3],
            [1,2,3]
          ],
          [
              [1,2,3],
              [1,2,3],
              [1,2,3]
          ]
          ]

FourD = [
          [
            [[1,2,3],[1,2,3],[1,2,3]],
            [[1,2,3],[1,2,3],[1,2,3]],
            [[1,2,3],[1,2,3],[1,2,3]]
          ],
          [
              [[1,2,3],[1,2,3],[1,2,3]],
              [[1,2,3],[1,2,3],[1,2,3]],
              [[1,2,3],[1,2,3],[1,2,3]]
          ]
          ]

LargeD = [
    [ [range(10)] * 10],
] * 512

def _normalize_array(a):
    if type(a) != type(()):
        return a
    ret = []
    for i in a:
        ret.append(_normalize_array(i))
    return ret

class ArrayTest(util.TestCase):
    def setUp(self):
        self.arr = gencache.EnsureDispatch("PyCOMTest.ArrayTest")
    def tearDown(self):
        self.arr = None
    def _doTest(self, array):
        self.arr.Array = array
        self.failUnlessEqual(_normalize_array(self.arr.Array), array)
    def testZeroD(self):
        self._doTest(ZeroD)
    def testOneDEmpty(self):
        self._doTest(OneDEmpty)
    def testOneD(self):
        self._doTest(OneD)
    def testTwoD(self):
        self._doTest(TwoD)
    def testThreeD(self):
        self._doTest(ThreeD)
    def testFourD(self):
        self._doTest(FourD)
    def testTwoD1(self):
        self._doTest(TwoD1)
    def testOneD1(self):
        self._doTest(OneD1)
    def testOneD2(self):
        self._doTest(OneD2)
    def testLargeD(self):
        self._doTest(LargeD)

if __name__ == "__main__":
    try:
        util.testmain()
    except SystemExit, rc:
        if not rc:
            raise
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.