Skip to content

Comments

Improve coverage for qdp.py by testing import fallback and stub behavior#1084

Open
alisha-1000 wants to merge 4 commits intoapache:mainfrom
alisha-1000:improve-qdp-py-coverage
Open

Improve coverage for qdp.py by testing import fallback and stub behavior#1084
alisha-1000 wants to merge 4 commits intoapache:mainfrom
alisha-1000:improve-qdp-py-coverage

Conversation

@alisha-1000
Copy link

Related Issues

Closes #1058


Changes

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • Test
  • CI/CD pipeline
  • Other

Why

The current test coverage for qumat/qdp.py does not fully validate the
fallback behavior when the native _qdp extension is unavailable.

This module contains import-time logic that dynamically assigns stub
implementations when the native extension is not installed. Ensuring
this fallback mechanism works correctly is important for reliability
in environments where the extension has not been built.


How

Added unit tests to explicitly exercise and validate:

  • Import fallback behavior when _qdp cannot be imported
  • Emission of ImportWarning during fallback
  • Stub class generation via _make_stub
  • Proper ImportError raised on stub instantiation
  • Correct module exports via __all__

These tests ensure that all functional code paths in qumat/qdp.py
are executed and validated.

Coverage impact:

  • qumat/qdp.py improved to ~93%, with all functional logic paths exercised.

Checklist

  • Added or updated unit tests for all changes
  • Added or updated documentation for all changes

@viiccwen
Copy link
Contributor

pls fix CI error.

@alisha-1000
Copy link
Author

@viiccwen Hi, I’ve addressed the CI issues (ruff + license header fixes) and pushed the updates.
Could you please help approve the workflows so CI can run? Thanks!

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.

[Feature] Enhance Module Testing Coverage

3 participants