From 4fb17882c89a7fabf3b34e5ab3ce661f8b4d8ba0 Mon Sep 17 00:00:00 2001 From: junkmd Date: Fri, 6 Dec 2024 22:00:11 +0900 Subject: [PATCH 1/2] Remove `SixDocChecker` from `test_showevents`. --- comtypes/test/test_showevents.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/comtypes/test/test_showevents.py b/comtypes/test/test_showevents.py index d6bf001c1..a39fecbee 100644 --- a/comtypes/test/test_showevents.py +++ b/comtypes/test/test_showevents.py @@ -1,24 +1,11 @@ import doctest -import sys -import re import unittest -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): 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 @@ -32,9 +19,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() """ From 89e8f035cfebbbb26c25cd6fa8609af325527293 Mon Sep 17 00:00:00 2001 From: junkmd Date: Fri, 6 Dec 2024 22:00:11 +0900 Subject: [PATCH 2/2] Add type annotations to `load_tests`. --- comtypes/test/test_showevents.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/comtypes/test/test_showevents.py b/comtypes/test/test_showevents.py index a39fecbee..6468499f2 100644 --- a/comtypes/test/test_showevents.py +++ b/comtypes/test/test_showevents.py @@ -1,8 +1,11 @@ import doctest import unittest +from typing import Optional -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))