0001 import unittest 0002 from win32com.client.gencache import EnsureDispatch 0003 from win32com.client.dynamic import DumbDispatch 0004 import win32com.test.util 0005 0006 class RegexTest(win32com.test.util.TestCase): 0007 def _CheckMatches(self, match, expected): 0008 found = [] 0009 for imatch in match: 0010 found.append(imatch.FirstIndex) 0011 self.assertEquals(list(found), list(expected)) 0012 0013 def _TestVBScriptRegex(self, re): 0014 StringToSearch = "Python python pYthon Python" 0015 re.Pattern = "Python" 0016 re.Global = True 0017 0018 re.IgnoreCase = True 0019 match = re.Execute(StringToSearch) 0020 expected = 0, 7, 14, 21 0021 self._CheckMatches(match, expected) 0022 0023 re.IgnoreCase = False 0024 match = re.Execute(StringToSearch) 0025 expected = 0, 21 0026 self._CheckMatches(match, expected) 0027 0028 def testDynamic(self): 0029 re = DumbDispatch("VBScript.Regexp") 0030 self._TestVBScriptRegex(re) 0031 0032 def testGenerated(self): 0033 re = EnsureDispatch("VBScript.Regexp") 0034 self._TestVBScriptRegex(re) 0035 0036 if __name__=='__main__': 0037 unittest.main() 0038
Generated by PyXR 0.9.4