Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

testvbscript_regexp.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import unittest
  2. import win32com.test.util
  3. from win32com.client.dynamic import DumbDispatch
  4. from win32com.client.gencache import EnsureDispatch
  5. class RegexTest(win32com.test.util.TestCase):
  6. def _CheckMatches(self, match, expected):
  7. found = []
  8. for imatch in match:
  9. found.append(imatch.FirstIndex)
  10. self.assertEqual(list(found), list(expected))
  11. def _TestVBScriptRegex(self, re):
  12. StringToSearch = "Python python pYthon Python"
  13. re.Pattern = "Python"
  14. re.Global = True
  15. re.IgnoreCase = True
  16. match = re.Execute(StringToSearch)
  17. expected = 0, 7, 14, 21
  18. self._CheckMatches(match, expected)
  19. re.IgnoreCase = False
  20. match = re.Execute(StringToSearch)
  21. expected = 0, 21
  22. self._CheckMatches(match, expected)
  23. def testDynamic(self):
  24. re = DumbDispatch("VBScript.Regexp")
  25. self._TestVBScriptRegex(re)
  26. def testGenerated(self):
  27. re = EnsureDispatch("VBScript.Regexp")
  28. self._TestVBScriptRegex(re)
  29. if __name__ == "__main__":
  30. unittest.main()