Add comprehensive tests for VARIANTEnumerator.#913
Merged
junkmd merged 6 commits intoenthought:mainfrom Jan 24, 2026
Merged
Conversation
This commit introduces a new test file `test/test_server_automation.py` containing `TestVARIANTEnumerator`. This test class verifies the functionality by creating and enumerating `IDispatch` objects and asserting the correct behavior of the `Next` method of `IEnumVARIANT`.
Refactored `test_Next` to `test_Next_single_item` and added `test_Next_multiple_items` to `TestVARIANTEnumerator` in `test_server_automation.py`. This new test verifies that `IEnumVARIANT.Next` can correctly fetch multiple items at once, ensuring proper handling of the `celt` parameter.
This commit introduces a new test method `test_Skip` to `TestVARIANTEnumerator` in `test_server_automation.py`. This test verifies the functionality of `IEnumVARIANT.Skip` by testing various skip scenarios, including skipping zero items, a single item, and more items than available, asserting correct return values for `Skip` and subsequent `Next` calls.
This commit introduces a new test method `test_Reset` to `TestVARIANTEnumerator` in `test/test_server_automation.py`. This test verifies the functionality of `IEnumVARIANT.Reset` by advancing the enumerator, resetting it, and then asserting that subsequent `Next` calls return items from the beginning of the enumeration.
This commit introduces a new test method `test_Clone` to `TestVARIANTEnumerator` in `test_server_automation.py`. This test verifies that calling `IEnumVARIANT.Clone` on a `VARIANTEnumerator` raises a `COMError` with `hresult.E_NOTIMPL`, as the `Clone` method is not implemented.
This commit introduces new test methods `test_dunder_iter` and `test_dunder_getitem` to `TestVARIANTEnumerator` in `test/test_server_automation.py`. `test_dunder_iter` verifies iteration support for `IEnumVARIANT` through `VARIANTEnumerator`. `test_dunder_getitem` confirms indexed access support and proper `IndexError` handling for out-of-bounds access.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #913 +/- ##
==========================================
+ Coverage 86.64% 87.10% +0.46%
==========================================
Files 133 134 +1
Lines 12600 12693 +93
==========================================
+ Hits 10917 11056 +139
+ Misses 1683 1637 -46 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This pull request introduces a new test module,
test_server_automation.py, dedicated to thoroughly testingserver.automation.VARIANTEnumerator.It includes tests for all essential methods of the
IEnumVARIANTinterface and ensures proper support for Python's iteration and indexing protocols (__iter__and__getitem__).Enhanced Test Coverage and Reliability
Ensures
IEnumVARIANTComplianceThe new tests verify the behavior of
Next(for both single and multiple item fetches),Skip,Reset, andClone(confirmingE_NOTIMPLwhere appropriate).This guarantees that
VARIANTEnumeratorcorrectly implements the standard COM enumeration contract, making it a reliable component for COM automation.Improves Pythonic Integration
By adding tests for
__iter__and__getitem__, this change ensures thatVARIANTEnumeratorseamlessly integrates with Python's native iterable and sequence protocols.