-
-
Notifications
You must be signed in to change notification settings - Fork 104
Enhance IStorage and IStream testing and refactoring.
#896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
junkmd
merged 10 commits into
enthought:main
from
junkmd:storage_stream_test_improvements
Jan 7, 2026
Merged
Enhance IStorage and IStream testing and refactoring.
#896
junkmd
merged 10 commits into
enthought:main
from
junkmd:storage_stream_test_improvements
Jan 7, 2026
Conversation
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
Implement new tests for `IStream.LockRegion` and `IStream.UnlockRegion` in `test_stream.py`. These tests verify the behavior of these methods for both memory-backed and file-backed streams.
Add comments to `comtypes/test/test_stream.py` explaining the expected behavior and limitations of the `IStream::Revert` method.
Renamed the helper function `_create_stream` in `comtypes/test/test_stream.py` to `_create_stream_on_hglobal` to better reflect its purpose of creating a stream backed by a global memory handle. All usages have been updated.
Replaced `msvidctl.dll` with `portabledeviceapi.dll` in `test/test_storage.py` for `IStorage` related tests. This change allows for the removal of the `contextlib.redirect_stdout` call, as `portabledeviceapi.dll` does not generate warning messages during module generation, unlike `msvidctl.dll`.
The `OPEN_STM_FLAG` constant in `comtypes/test/test_storage.py` was identified as unused and has been removed to clean up the codebase.
Adds comments to `comtypes/test/test_storage.py` to clarify why `OpenStream` and `EnumElements` are currently skipped due to difficulties in calling remote-side auto-generated methods.
Refactored `Test_IStorage` in `test_storage.py` to introduce new constants. These constants standardize the creation and access modes for `IStorage` and `IStream` objects within the tests, improving readability and reducing redundancy.
Introduced `test_SetClass` in `test_storage.py` to verify the `IStorage.SetClass` method's functionality, including setting and resetting CLSIDs.
…ge.py` Standardize the variable name for `assertRaises` context managers from `ctx` to `cm` within `comtypes/test/test_storage.py` for consistency.
Introduced `test_Stat` in `test_storage.py` to thoroughly verify the behavior of the `IStorage.Stat` method, including error handling for invalid flags and correct retrieval of `tagSTATSTG` information. The `_create_docfile` helper method was updated to allow specifying a file path, enabling more precise control over test document creation and allowing for the validation of temporary file creation and existence.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #896 +/- ##
==========================================
+ Coverage 85.31% 85.40% +0.09%
==========================================
Files 126 126
Lines 11941 12018 +77
==========================================
+ Hits 10187 10264 +77
Misses 1754 1754 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Tests Added:
IStorage.StatTesting:Comprehensive tests of
IStorage.Statbehavior, covering error handling for invalid flags and correcttagSTATSTGretrieval. This ensures the reliability of storage inspection and proper handling of compound files.IStorage.SetClassTesting:Verifies the ability to correctly set and reset CLSIDs for
IStorageobjects. This is crucial for applications that need to dynamically manage the type identity of stored objects within compound files.IStream.LockRegion/UnlockRegionTesting:New tests for locking/unlocking regions in
IStreamfor both memory-backed and file-backed streams. This confirms correct concurrency control and data integrity, particularly for file-backed streams where concurrent access from other processes is a concern, preventing race conditions or data inconsistencies.Refactorings for Maintainability:
Standardized
assertRaisescontext manager variable names (cm) and removed unused constants.Renamed test helper methods and constants for better clarity regarding its function.
Test Clarity:
Added comments to clarify why certain
IStoragemethods (OpenStream,EnumElements) are currently not fully tested due to implementation complexities.IStream::RevertBehavior Clarification:Documented the expected behavior and limitations of
IStream::Revertfor different stream types.Switched
IStoragetests frommsvidctl.dlltoportabledeviceapi.dll, eliminating warnings during module generation and simplifying the test environment setup.