Skip to content

Add record SAFEARRAY tests and a test-double COM server. - #980

Merged
junkmd merged 4 commits into
enthought:mainfrom
junkmd:issue_63_rec_safearray_characterization_tests
Nov 2, 2026
Merged

junkmd merged 4 commits into
enthought:mainfrom
junkmd:issue_63_rec_safearray_characterization_tests

Conversation

@junkmd

@junkmd junkmd commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Arrays of records (VT_ARRAY | VT_RECORD) are only partially supported by comtypes today.
Through a typed (vtable) interface, record arrays go in and come out correctly.
Through IDispatch::Invovke, they can be sent to a server as typed SAFEARRAYs, but a record array coming back fails with KeyError: 36 (#63; #104 proposes unpacking them).

What is missing is not only the fix, but a way to know whether any change in this area is correct.
A fix for #63 touches the code that unpacks record arrays, and that code is shared with the vtable path, which works today.
Without a baseline, a change can look right on the path it targets while silently regressing the other one.
It is also hard to test against existing COM components: nothing predictable accepts and returns record arrays with known contents.

This PR adds that baseline before touching any library code, for three reasons:

Two record kinds are tested on purpose. Integer-only records isolate marshaling. BSTR records add ownership of heap-allocated strings, which is where unpacking changes are most likely to go wrong.

Summary

  • One out-of-process COM server component serves both IDualRecordSafearrayTest (vtable) and IDispRecordSafearrayTest (dispatch).
  • The same scenarios run over both paths through a mixin, so a difference between the paths appears as a difference in assertions.

What this does not do:

  • It does not change production code.

Related: #63, #104. This does not close either.

…enthought#63.

Some of the dispatch-path tests that use `assertRaises` pin down the
current behavior, which is a known limitation rather than the intended
contract. Unlike the cases where the server legitimately rejects the
input (e.g. empty arrays returning `E_INVALIDARG`), those should become
normal-path tests once enthought#63 is fixed.

The `CHARACTERIZATION(enthought#63)` message is reported only when the call no
longer raises, which is exactly when someone has fixed the issue, so the
failure itself tells them what to do next.
@junkmd junkmd added this to the 1.5.0 / Support Python 3.15 milestone Nov 2, 2026
@junkmd junkmd added the tests enhance or fix tests label Nov 2, 2026
@codecov-commenter

codecov-commenter commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.09091% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.76%. Comparing base (2b4e5f1) to head (38bfe8d).

Files with missing lines Patch % Lines
comtypes/test/test_record_safearray_bstr.py 99.10% 2 Missing ⚠️
comtypes/test/test_record_safearray_value.py 99.07% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #980      +/-   ##
==========================================
+ Coverage   90.50%   90.76%   +0.26%     
==========================================
  Files         145      147       +2     
  Lines       14831    15271     +440     
==========================================
+ Hits        13423    13861     +438     
- Misses       1408     1410       +2     

☔ View full report in Codecov by Harness.
📢 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 c34d320 into enthought:main Nov 2, 2026
145 of 151 checks passed
@junkmd
junkmd deleted the issue_63_rec_safearray_characterization_tests branch November 2, 2026 22:12
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.

VARIANT._get_value cannot unpack arrays of arbitrary type

2 participants