Skip to content

Conversation

@junkmd
Copy link
Collaborator

@junkmd junkmd commented Dec 26, 2025

I noticed that naming tests after specific COM libraries, like the old test_ie.py, makes them brittle.
When a COM library becomes unavailable, the test breaks, and its original purpose can be lost.
To address this, I have renamed test files to reflect their testing goals rather than the specific libraries they use.
This will help future maintainers understand the test's intent and find alternative libraries if needed.

  • comtypes/test/test_msi.py is renamed to comtypes/test/test_puredispatch.py.
  • comtypes/test/test_wmi.py is renamed to comtypes/test/test_variant_outparam.py.

Additionally, I encountered an issue in comtypes/test/test_eventinterface.py where the entire module was being skipped by setUpModule.
To make it easier to add new tests for event interfaces (outgoing interfaces), I have replaced the module-level skip with individual @unittest.skip decorators on the test methods.

This commit enhances tests using WMI.

It ensures that `ISWbemProperty.Value` behaves correctly as a property with an
`[out] POINTER(VARIANT)` parameter by:
- Retrieving type information using `GetTypeInfo` and `GetRefTypeInfo`.
- Inspecting `wParamFlags` to confirm `PARAMFLAG_FOUT | PARAMFLAG_FRETVAL`.
- Validating the `vt` of the parameter as `VT_PTR` to `VT_VARIANT`.
Rename `Test` class to `TestWMI` for better clarity.
Replace direct attribute access of `WbemScripting.wbemPrivilegeCreateToken`
with `hasattr` check to enhance test robustness.
Remove redundant `prop.Value` access as it is already assigned to `result`.
The test file `test_msi.py` has been renamed to `test_puredispatch.py` to
better reflect its content and purpose.
Move the test skipping logic from module-level `setUpModule` to individual
`ut.skip` decorators for test methods.
@junkmd junkmd added this to the 1.4.15 milestone Dec 26, 2025
@junkmd junkmd added the tests enhance or fix tests label Dec 26, 2025
@codecov
Copy link

codecov bot commented Dec 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.04%. Comparing base (ec8ac0d) to head (c6bee28).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #890      +/-   ##
==========================================
+ Coverage   85.02%   85.04%   +0.01%     
==========================================
  Files         126      126              
  Lines       11716    11726      +10     
==========================================
+ Hits         9962     9972      +10     
  Misses       1754     1754              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@junkmd junkmd merged commit 7c01639 into enthought:main Dec 26, 2025
123 of 150 checks passed
@junkmd junkmd deleted the maintainability_clarity_improvements_for_tests branch December 26, 2025 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests enhance or fix tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant