Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions comtypes/test/test_showevents.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import doctest
import sys
import re
import unittest
from typing import Optional


class SixDocChecker(doctest.OutputChecker):
# see https://dirkjan.ochtman.nl/writing/2014/07/06/single-source-python-23-doctests.html
def check_output(self, want, got, optionflags):
if sys.version_info >= (3, 0):
want = re.sub(r"u'(.*?)'", r"'\1'", want)
want = re.sub(r'u"(.*?)"', r'"\1"', want)
return doctest.OutputChecker.check_output(self, want, got, optionflags)


def load_tests(loader, tests, ignore):
def load_tests(
loader: unittest.TestLoader, tests: unittest.TestSuite, pattern: Optional[str]
) -> unittest.TestSuite:
import comtypes.test.test_showevents

tests.addTests(
doctest.DocTestSuite(comtypes.test.test_showevents, checker=SixDocChecker())
)
tests.addTests(doctest.DocTestSuite(comtypes.test.test_showevents))
return tests


Expand All @@ -32,9 +22,9 @@ def StdFont_ShowEvents(self):
>>> conn = ShowEvents(font)
# event found: FontEvents_FontChanged
>>> font.Name = 'Arial'
Event FontEvents_FontChanged(None, u'Name')
Event FontEvents_FontChanged(None, 'Name')
>>> font.Italic = True
Event FontEvents_FontChanged(None, u'Italic')
Event FontEvents_FontChanged(None, 'Italic')
>>> PumpEvents(0.01) # just calling. assertion does in `test_pump_events.py`
>>> conn.disconnect()
"""
Expand Down