Skip to content

Commit 9126c8c

Browse files
authored
(A part of) Remove Internet Explorer dependencies from tests. (#888)
* test: Remove commented-out debug prints from `test_casesensitivity.py`. Removes old, commented-out `print` statements that were used for debugging during development and are no longer needed. This cleans up the test file. * test: Replace Internet Explorer COM objects with `MSVidCtlLib` in `test_casesensitivity.py`. The `test_casesensitivity.py` file has been updated to remove its dependency on Internet Explorer's `shdocvw.dll` COM objects. The test now uses `MSVidCtlLib` interfaces instead. This is part of the ongoing effort to reduce `comtypes`'s reliance on Internet Explorer components in tests. * refactor: Rename `test_ie.py` to `test_eventinterface.py` for preparing IE-independent event testing. The `test_ie.py` file is planned for refactoring to test `comtypes`' event handling mechanism without relying on Internet Explorer. The primary goal is to verify how `GetEvents` behaves when the `interface` argument is explicitly specified versus when it is omitted, using an object that has multiple outgoing event interfaces. * docs: Add test perspective comments to `test_eventinterface.py`. * build: Update ruff ignores for renamed test file. In `pyproject.toml`, the `per-file-ignores` configuration for ruff has been updated. The entry for `comtypes/test/test_ie.py` is changed to `comtypes/test/test_eventinterface.py` to reflect the recent file rename.
1 parent ece82ed commit 9126c8c

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

comtypes/test/test_casesensitivity.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
1+
import contextlib
12
import unittest
23

34
from comtypes.client import GetModule
45

5-
iem = GetModule("shdocvw.dll")
6+
with contextlib.redirect_stdout(None): # supress warnings
7+
GetModule("msvidctl.dll")
8+
from comtypes.gen import MSVidCtlLib as msvidctl
69

710

811
class TestCase(unittest.TestCase):
912
def test(self):
10-
from comtypes.client import GetModule
11-
12-
iem = GetModule("shdocvw.dll")
13-
1413
# IDispatch(IUnknown)
15-
# IWebBrowser(IDispatch)
16-
# IWebBrowserApp(IWebBrowser)
17-
# IWebBrowser2(IWebBrowserApp)
18-
19-
# print iem.IWebBrowser2.mro()
20-
21-
self.assertTrue(issubclass(iem.IWebBrowser2, iem.IWebBrowserApp))
22-
self.assertTrue(issubclass(iem.IWebBrowserApp, iem.IWebBrowser))
14+
# IMSVidDevice(IDispatch)
15+
# IMSVidInputDevice(IMSVidDevice)
16+
# IMSVidPlayback(IMSVidOutputDevice)
2317

24-
# print sorted(iem.IWebBrowser.__map_case__.keys())
25-
# print "=" * 42
26-
# print sorted(iem.IWebBrowserApp.__map_case__.keys())
27-
# print "=" * 42
28-
# print sorted(iem.IWebBrowser2.__map_case__.keys())
29-
# print "=" * 42
18+
self.assertTrue(issubclass(msvidctl.IMSVidPlayback, msvidctl.IMSVidInputDevice))
19+
self.assertTrue(issubclass(msvidctl.IMSVidInputDevice, msvidctl.IMSVidDevice))
3020

3121
# names in the base class __map_case__ must also appear in the
3222
# subclass.
33-
for name in iem.IWebBrowser.__map_case__:
34-
self.assertTrue(name in iem.IWebBrowserApp.__map_case__, f"{name} missing")
35-
self.assertTrue(name in iem.IWebBrowser2.__map_case__, f"{name} missing")
23+
for name in msvidctl.IMSVidDevice.__map_case__:
24+
self.assertIn(name, msvidctl.IMSVidInputDevice.__map_case__)
25+
self.assertIn(name, msvidctl.IMSVidPlayback.__map_case__)
3626

37-
for name in iem.IWebBrowserApp.__map_case__:
38-
self.assertTrue(name in iem.IWebBrowser2.__map_case__, f"{name} missing")
27+
for name in msvidctl.IMSVidInputDevice.__map_case__:
28+
self.assertIn(name, msvidctl.IMSVidPlayback.__map_case__)
3929

4030

4131
if __name__ == "__main__":
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77

88
def setUpModule():
9+
# The primary goal is to verify how `GetEvents` behaves when the
10+
# `interface` argument is explicitly specified versus when it is omitted,
11+
# using an object that has multiple outgoing event interfaces.
912
raise ut.SkipTest(
1013
"External test dependencies like this seem bad. Find a different built-in "
1114
"win32 API to use."

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ignore = ["E402"]
8888
"comtypes/test/test_agilent.py" = ["F401", "F841"]
8989
"comtypes/test/test_client.py" = ["F401"]
9090
"comtypes/test/test_dict.py" = ["F841"]
91-
"comtypes/test/test_ie.py" = ["F841"]
91+
"comtypes/test/test_eventinterface.py" = ["F841"]
9292
"comtypes/test/test_outparam.py" = ["F841"]
9393
"comtypes/test/test_sapi.py" = ["E401"]
9494
"comtypes/test/test_server.py" = ["F401", "F841"]

0 commit comments

Comments
 (0)