Skip to content

Conversation

@junkmd
Copy link
Collaborator

@junkmd junkmd commented Jan 24, 2026

Overview

This pull request expands the test coverage for COM Moniker functionalities. It introduces new test cases and helper functions to validate behaviors of IMoniker, IBindCtx, and IRunningObjectTable interfaces, ensuring robust and reliable interactions with COM objects.

Value Proposition

Comprehensive Functionality Testing

Previously, several core methods lacked dedicated test coverage. This change introduces new tests.

Improved Helper Functions and Constants

To facilitate these tests, necessary COM constants like MKSYS_GENERICCOMPOSITE, along with helper functions like _CreateGenericComposite, have been exposed, improving the testability and clarity of COM interactions.

This extensive test suite provides a higher degree of assurance in the correctness and stability for systems relying on these fundamental COM mechanisms.

junkmd added 15 commits January 24, 2026 12:00
Introduces `Test_IsEqual` class to `test/test_moniker.py` to verify the correct
functionality of `IsEqual` method for monikers. This test ensures that monikers
with identical item IDs are correctly identified as equal, while those with
different item IDs are not.
Introduces `Test_Hash` class to `test/test_moniker.py` to verify the correct
functionality of the `Hash` method for monikers. This test ensures that
monikers with identical item IDs produce the same hash value, while those with
different item IDs produce different hash values.
Introduces `Test_ComposeWith` to `test/test_moniker.py` to verify the
`ComposeWith` method. This test ensures that composing item monikers results in
a `CLSID_CompositeMoniker`.
It also validates that when `fOnlyIfNotGeneric=True`, `ComposeWith` correctly
raises a `COMError` with `MK_E_NEEDGENERIC`, indicating that the moniker cannot
be composed generically.
Constants `CLSID_CompositeMoniker` and `MK_E_NEEDGENERIC` were added to
`test/monikers_helper.py` to support this test.
Introduces `Test_Enum` class with `test_generic_composite` method to
`test/test_moniker.py`. This test verifies the `Enum` method of composite
monikers, ensuring it correctly returns an `IEnumMoniker` instance. It uses the
newly added `_CreateGenericComposite` helper in `test/monikers_helper.py`.
This test verifies the correct behavior of `IsSystemMoniker`, `GetDisplayName`,
`GetClassID`, and `Inverse` methods for generic composite monikers.
The `MKSYS_GENERICCOMPOSITE` constant was added to `monikers_helper.py` to
support this test.
Introduces `Test_RemoteBindToObject` class with `test_file` method to
`test/test_moniker.py`. This test verifies the `RemoteBindToObject` method for
file monikers, ensuring correct binding to `IPersistFile`.
The `_CreateFileMoniker` helper function was added to `monikers_helper.py` to
support this test.
Introduces `test_file` method to `Test_IsSystemMoniker_GetDisplayName_Inverse`
in `test/test_moniker.py`. This test verifies the correct behavior of
`IsSystemMoniker`, `GetDisplayName`, `GetClassID`, and `Inverse` methods for
file monikers. The `MKSYS_FILEMONIKER` and `CLSID_FileMoniker` constants were
added to `monikers_helper.py` to support this test.
Introduces `Test_CommonPrefixWith` class with `test_file` method to
`test/test_moniker.py`. This test verifies the `CommonPrefixWith` method for
file monikers, ensuring it correctly identifies the common directory path
between different file monikers.
Introduces `Test_RelativePathTo` class with `test_file` method to
`/test/test_moniker.py`. This test verifies the `RelativePathTo` method for
file monikers, ensuring it correctly calculates the relative path between two
file monikers, mirroring `pathlib.Path.relative_to`.
…dOptions`.

This commit introduces a new test class `Test_Set_Get_BindOptions` to
`test/test_bctx.py`. It verifies the correct functionality of `SetBindOptions`
and `GetBindOptions` by setting and retrieving `tagBIND_OPTS2` values and
asserting their correctness.
…thods.

This commit introduces a new test class `Test_Get_Register_Revoke_ObjectParam`
to `test/test_bctx.py`. It verifies the functionality of `GetObjectParam`,
`RegisterObjectParam`, and `RevokeObjectParam` by registering and revoking a
COM object and asserting its presence or absence.
This commit introduces a new test class to `test/test_bctx.py`.
It verifies the functionality of `RegisterObjectBound`, `RevokeObjectBound`,
and `ReleaseBoundObjects` by registering and unregistering a COM object within
the bind context.
Add `_get_long_path_name` to `test_moniker.py`.
This change ensures consistent path normalization across test environments,
preventing failures due to short path vs. long path discrepancies.
Replaced the dynamic calculation of relative paths using `Path.relative_to`
with a literal string in `Test_RelativePathTo.test_file`.
This simplifies the test logic and resolves the `TypeError` caused by
`walk_up=True` in older Python environments, aligning with the goal of reducing
complexity.
@codecov
Copy link

codecov bot commented Jan 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.64%. Comparing base (526af9a) to head (2e53d6a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #912      +/-   ##
==========================================
+ Coverage   86.45%   86.64%   +0.18%     
==========================================
  Files         133      133              
  Lines       12428    12600     +172     
==========================================
+ Hits        10745    10917     +172     
  Misses       1683     1683              

☔ 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 added the tests enhance or fix tests label Jan 24, 2026
@junkmd junkmd added this to the 1.4.16 milestone Jan 24, 2026
@junkmd junkmd merged commit da3634c into enthought:main Jan 24, 2026
120 of 150 checks passed
@junkmd junkmd deleted the more_monikers_tests branch January 24, 2026 05:13
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