home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2763 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.9 KB  |  46 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import unittest
  5. from win32com.client.gencache import EnsureDispatch
  6. from win32com.client.dynamic import DumbDispatch
  7. import win32com.test.util as win32com
  8.  
  9. class RegexTest(win32com.test.util.TestCase):
  10.     
  11.     def _CheckMatches(self, match, expected):
  12.         found = []
  13.         for imatch in match:
  14.             found.append(imatch.FirstIndex)
  15.         
  16.         self.assertEquals(list(found), list(expected))
  17.  
  18.     
  19.     def _TestVBScriptRegex(self, re):
  20.         StringToSearch = 'Python python pYthon Python'
  21.         re.Pattern = 'Python'
  22.         re.Global = True
  23.         re.IgnoreCase = True
  24.         match = re.Execute(StringToSearch)
  25.         expected = (0, 7, 14, 21)
  26.         self._CheckMatches(match, expected)
  27.         re.IgnoreCase = False
  28.         match = re.Execute(StringToSearch)
  29.         expected = (0, 21)
  30.         self._CheckMatches(match, expected)
  31.  
  32.     
  33.     def testDynamic(self):
  34.         re = DumbDispatch('VBScript.Regexp')
  35.         self._TestVBScriptRegex(re)
  36.  
  37.     
  38.     def testGenerated(self):
  39.         re = EnsureDispatch('VBScript.Regexp')
  40.         self._TestVBScriptRegex(re)
  41.  
  42.  
  43. if __name__ == '__main__':
  44.     unittest.main()
  45.  
  46.