-
-
Notifications
You must be signed in to change notification settings - Fork 104
Enhance dynamic dispatch and client testing.
#909
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
Merged
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
Refactor `dynamic.Dispatch` tests in `test_client_dynamic.py` by removing `mock` usage. Tests now directly create COM objects with `CreateObject` to validate `lazybind.Dispatch` and `dynamic._Dispatch` instances more accurately.
…roduce `Test_lazybind_Dispatch`. Adjust index access assertion in `lazybind.Dispatch` tests to reflect its `None` return for non-existent keys, contrasting with `dynamic._Dispatch`'s `IndexError`. Add comments explaining these behaviors.
…s tests. Add specific tests for `dynamic.Dispatch` and `lazybind.Dispatch` to verify behavior when attempting to access non-existent members. `dynamic.Dispatch` is expected to raise `COMError` with `hresult.DISP_E_UNKNOWNNAME`, while `lazybind.Dispatch` should raise `NameError`.
… and `lazybind.Dispatch`. These tests verify property and method access on the `WindowsInstaller.Installer` COM object, ensuring proper interaction with real-world COM components.
…ient_dynamic.py`.
… `dynamic=True`. This change adds a test case to `Test_MSVidCtlLib` in `test_getactiveobj.py` to confirm that `comtypes.client.GetActiveObject` raises a `ValueError` when both `dynamic=True` and an `interface` are provided simultaneously. Additionally, it verifies that `GetActiveObject` correctly returns a `comtypes.client.lazybind.Dispatch` object with an identical hash to the original object when `dynamic=True` is specified.
…th `interface`. This test case confirms that `comtypes.client.CreateObject` correctly raises a `ValueError` when an `interface` is provided alongside `dynamic=True`, preventing a potential misuse of the API.
Introduces a new test class `Test_CoGetObject` to thoroughly verify the functionality of `comtypes.client.CoGetObject`. It includes test cases for successfully returning an interface pointer and a dynamic dispatch object, as well as confirming that a `ValueError` is raised when both `dynamic=True` and an `interface` are simultaneously provided.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #909 +/- ##
==========================================
+ Coverage 86.24% 86.41% +0.16%
==========================================
Files 132 132
Lines 12334 12399 +65
==========================================
+ Hits 10638 10714 +76
+ Misses 1696 1685 -11 ☔ 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.
Overview
This pull request enhances the tests for object creation functions (
CreateObject,CoGetObject,GetActiveObject).The changes remove reliance on mocking in dynamic dispatch tests, ensuring that real COM object interactions are validated.
Comprehensive
CoGetObjectTestingThe
CoGetObjectfunction now has dedicated, comprehensive tests ensuring it correctly returns both specific COM interfaces and dynamic dispatch objects.Improved Dynamic Dispatch Behavior Verification
Tests for
dynamic.Dispatchandlazybind.Dispatchhave been refactored to use live COM objects instead of mocks. This change moves from simulated scenarios to real-world COM interactions, thus increasing the reliability of these core dynamic dispatch mechanisms.Stricter API Usage Enforcement
New tests ensure that
CreateObject,CoGetObject, andGetActiveObjectcorrectly raiseValueErrorwhendynamic=Trueis used in conjunction with an explicitinterfaceargument.