Skip to content

Add tests for explicit string SAFEARRAY types inside VARIANTs. - #964

Merged
junkmd merged 1 commit into
enthought:mainfrom
junkmd:string_array_testing
Oct 11, 2026
Merged

junkmd merged 1 commit into
enthought:mainfrom
junkmd:string_array_testing

Conversation

@junkmd

@junkmd junkmd commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Related to #80 and #347

Summary

This PR adds a native COM test server and Python tests for explicitly typed string SAFEARRAYs passed inside VARIANTs.

The tests cover conversions between SAFEARRAY(VARIANT) and SAFEARRAY(BSTR), repetition of both array types, arrays created with create and from_param, and DISP_E_TYPEMISMATCH for incorrect element types
The new test server is registered in the IDL, class factory, and build files.

The PR does not change the default conversion of list[str] or tuple[str, ...].

Scope and design decision

This PR does not change the default conversion of list[str] or tuple[str, ...].

Normal Python string arrays continue to be represented as SAFEARRAY(VARIANT). Changing the default to SAFEARRAY(BSTR) would break existing Excel tests and change the array type received by COM servers, so backward compatibility takes priority.

Some COM servers accept VARIANT(BSTR) but reject VARIANT(VARIANT(BSTR)).
For those servers, callers can explicitly create and pass a SAFEARRAY(BSTR).
The tests in this PR verify that this explicit typed-array approach works without changing existing defaults.

Expected outcome

COM servers that require SAFEARRAY(BSTR) can be supported by explicitly specifying that type, while existing Excel compatibility and normal Python string-array behavior remain unchanged.
A future public helper can improve usability without changing this compatibility policy.

Add a native COM test server and Python tests covering conversions and
repetition of `SAFEARRAY(VARIANT)` and `SAFEARRAY(BSTR)` values. Verify that
typed-array mismatches return `DISP_E_TYPEMISMATCH` while preserving the
existing default string-array behavior.
@junkmd junkmd added this to the `Array[BSTR]` implementation milestone Oct 11, 2026
@junkmd junkmd added the tests enhance or fix tests label Oct 11, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.40260% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.21%. Comparing base (b91b041) to head (8200a77).

Files with missing lines Patch % Lines
...types/test/test_string_safearray_inside_variant.py 97.40% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #964      +/-   ##
==========================================
+ Coverage   89.16%   89.21%   +0.04%     
==========================================
  Files         141      142       +1     
  Lines       13793    13870      +77     
==========================================
+ Hits        12299    12374      +75     
- Misses       1494     1496       +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 939341c into enthought:main Oct 11, 2026
265 of 301 checks passed
@junkmd
junkmd deleted the string_array_testing branch October 11, 2026 02:07
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.

2 participants