0001 # Originally contributed by Stefan Schukat as part of this arbitrary-sized 0002 # arrays patch. 0003 from win32com.client import gencache 0004 import util 0005 import unittest 0006 0007 ZeroD = 0 0008 OneDEmpty = [] 0009 OneD = [1,2,3] 0010 TwoD = [ 0011 [1,2,3], 0012 [1,2,3], 0013 [1,2,3] 0014 ] 0015 0016 TwoD1 = [ 0017 [ 0018 [1,2,3,5], 0019 [1,2,3], 0020 [1,2,3] 0021 ], 0022 [ 0023 [1,2,3], 0024 [1,2,3], 0025 [1,2,3] 0026 ] 0027 ] 0028 0029 OneD1 = [ 0030 [ 0031 [1,2,3], 0032 [1,2,3], 0033 [1,2,3] 0034 ], 0035 [ 0036 [1,2,3], 0037 [1,2,3] 0038 ] 0039 ] 0040 0041 OneD2 = [ 0042 [1,2,3], 0043 [1,2,3,4,5], 0044 [ 0045 [1,2,3,4,5], 0046 [1,2,3,4,5], 0047 [1,2,3,4,5] 0048 ] 0049 ] 0050 0051 0052 ThreeD = [ 0053 [ 0054 [1,2,3], 0055 [1,2,3], 0056 [1,2,3] 0057 ], 0058 [ 0059 [1,2,3], 0060 [1,2,3], 0061 [1,2,3] 0062 ] 0063 ] 0064 0065 FourD = [ 0066 [ 0067 [[1,2,3],[1,2,3],[1,2,3]], 0068 [[1,2,3],[1,2,3],[1,2,3]], 0069 [[1,2,3],[1,2,3],[1,2,3]] 0070 ], 0071 [ 0072 [[1,2,3],[1,2,3],[1,2,3]], 0073 [[1,2,3],[1,2,3],[1,2,3]], 0074 [[1,2,3],[1,2,3],[1,2,3]] 0075 ] 0076 ] 0077 0078 LargeD = [ 0079 [ [range(10)] * 10], 0080 ] * 512 0081 0082 def _normalize_array(a): 0083 if type(a) != type(()): 0084 return a 0085 ret = [] 0086 for i in a: 0087 ret.append(_normalize_array(i)) 0088 return ret 0089 0090 class ArrayTest(util.TestCase): 0091 def setUp(self): 0092 self.arr = gencache.EnsureDispatch("PyCOMTest.ArrayTest") 0093 def tearDown(self): 0094 self.arr = None 0095 def _doTest(self, array): 0096 self.arr.Array = array 0097 self.failUnlessEqual(_normalize_array(self.arr.Array), array) 0098 def testZeroD(self): 0099 self._doTest(ZeroD) 0100 def testOneDEmpty(self): 0101 self._doTest(OneDEmpty) 0102 def testOneD(self): 0103 self._doTest(OneD) 0104 def testTwoD(self): 0105 self._doTest(TwoD) 0106 def testThreeD(self): 0107 self._doTest(ThreeD) 0108 def testFourD(self): 0109 self._doTest(FourD) 0110 def testTwoD1(self): 0111 self._doTest(TwoD1) 0112 def testOneD1(self): 0113 self._doTest(OneD1) 0114 def testOneD2(self): 0115 self._doTest(OneD2) 0116 def testLargeD(self): 0117 self._doTest(LargeD) 0118 0119 if __name__ == "__main__": 0120 try: 0121 util.testmain() 0122 except SystemExit, rc: 0123 if not rc: 0124 raise 0125
Generated by PyXR 0.9.4