Skip to content

Refactor test_basic.py to use public APIs.#936

Merged
junkmd merged 6 commits intoenthought:mainfrom
junkmd:createtypelib_basic_tests
Mar 29, 2026
Merged

Refactor test_basic.py to use public APIs.#936
junkmd merged 6 commits intoenthought:mainfrom
junkmd:createtypelib_basic_tests

Conversation

@junkmd
Copy link
Copy Markdown
Collaborator

@junkmd junkmd commented Mar 29, 2026

Overview

This PR refactors test/test_basic.py to 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 QueryInterface now utilize the public CreateTypeLib function 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.

junkmd added 6 commits March 29, 2026 15:52
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`.
@junkmd junkmd added this to the 1.4.17 milestone Mar 29, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.97%. Comparing base (80ed427) to head (bbdf3c8).
⚠️ Report is 1 commits behind head on main.

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.
📢 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 8fec088 into enthought:main Mar 29, 2026
52 checks passed
@junkmd junkmd deleted the createtypelib_basic_tests branch March 30, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant