Skip to content

Conversation

@junkmd
Copy link
Collaborator

@junkmd junkmd commented Jan 7, 2026

Tests Added:

  • IStorage.Stat Testing:
    Comprehensive tests of IStorage.Stat behavior, covering error handling for invalid flags and correct tagSTATSTG retrieval. This ensures the reliability of storage inspection and proper handling of compound files.
  • IStorage.SetClass Testing:
    Verifies the ability to correctly set and reset CLSIDs for IStorage objects. This is crucial for applications that need to dynamically manage the type identity of stored objects within compound files.
  • IStream.LockRegion/UnlockRegion Testing:
    New tests for locking/unlocking regions in IStream for 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:

  • Improved Test Code Consistency:
    Standardized assertRaises context manager variable names (cm) and removed unused constants.
  • Clearer Naming:
    Renamed test helper methods and constants for better clarity regarding its function.

Test Clarity:

  • Explanations for Skipped Tests:
    Added comments to clarify why certain IStorage methods (OpenStream, EnumElements) are currently not fully tested due to implementation complexities.
  • IStream::Revert Behavior Clarification:
    Documented the expected behavior and limitations of IStream::Revert for different stream types.
  • Module for Testing:
    Switched IStorage tests from msvidctl.dll to portabledeviceapi.dll, eliminating warnings during module generation and simplifying the test environment setup.

junkmd added 10 commits January 7, 2026 22:42
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.
@junkmd junkmd added this to the 1.4.15 milestone Jan 7, 2026
@junkmd junkmd added the tests enhance or fix tests label Jan 7, 2026
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.40%. Comparing base (9c742c8) to head (2007a07).
⚠️ Report is 1 commits behind head on main.

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.
📢 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 5932fe9 into enthought:main Jan 7, 2026
98 of 101 checks passed
@junkmd junkmd deleted the storage_stream_test_improvements branch January 7, 2026 14:53
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