Refactor test_basic.py to use public APIs.#936
Merged
junkmd merged 6 commits intoenthought:mainfrom Mar 29, 2026
Merged
Conversation
Relocate `CreateTypeLib` from `BasicTest.test_guid` to the top level of `test/test_basic.py` to follow project conventions.
Replace magic number `1` with `SYS_WIN32` in `_CreateTypeLib2` calls.
Replace internal `_CreateTypeLib2` calls with public `CreateTypeLib`. The primary goal of these tests is to verify the basic mechanics of COM pointers, such as reference counting and `QueryInterface` behavior, which are common to all COM interfaces. Testing low-level, private functions like `_CreateTypeLib2` is not the objective here.
Remove the redundant inline import of `IUnknown` from the `test_IUnknown` method, as it is already imported at the top level of `test/test_basic.py`.
Remove a redundant commented-out `import` statement from the top of `test/test_basic.py`.
Add assertions to `BasicTest.test_refcounts` and `BasicTest.test_qi` to verify that the object returned by `CreateTypeLib` is an instance of `IUnknown`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #936 +/- ##
=======================================
Coverage 88.97% 88.97%
=======================================
Files 139 139
Lines 13633 13633
=======================================
Hits 12130 12130
Misses 1503 1503 ☔ 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 PR refactors
test/test_basic.pyto improve maintainability.It primarily replaces internal, low-level function calls with public APIs for fundamental COM behavior verification and cleans up redundant code.
Decoupling from Internal Implementations
The tests for COM pointer reference counting and
QueryInterfacenow utilize the publicCreateTypeLibfunction instead of the private_CreateTypeLib2.Referencing the comments from #764 helps future maintainers easily understand the underlying intent of these tests.
Improved Code Clarity and Maintainability
Redundant inline imports, magic numbers, and commented-out code have been removed or replaced with named constants like
SYS_WIN32.