Skip to content

chore: unit test fixes#57

Merged
araujof merged 1 commit into
contextforge-org:mainfrom
tedhabeck:2026-06-01-unit-test-fix
Jun 1, 2026
Merged

chore: unit test fixes#57
araujof merged 1 commit into
contextforge-org:mainfrom
tedhabeck:2026-06-01-unit-test-fix

Conversation

@tedhabeck
Copy link
Copy Markdown
Contributor

Summary

What does this PR add or change?

fixed all 5 failing unit tests in tests/unit/cpex/tools/test_cli.py:

Root Cause:
The tests were using pytest.raises(click.exceptions.Exit) to catch exceptions, but the code raises typer.Exit. While typer.Exit is internally based on Click's Exit exception, pytest's exception matching requires the exact type.

Changes Made:

  1. Added import typer to the test file imports (line 19)
  2. Changed all failing tests to use pytest.raises(typer.Exit) instead of pytest.raises(click.exceptions.Exit)
  3. Fixed test_install_requires_type_parameter to properly mock _install_from_monorepo to avoid actual installation attempts
  4. Fixed test_uninstall_plugin_not_found to mock PluginRegistry to prevent loading the actual registry

Tests Fixed:

  • ✅ TestInstallFunction::test_install_requires_type_parameter
  • ✅ TestUninstallFunction::test_uninstall_plugin_not_found
  • ✅ TestUninstallFunction::test_uninstall_handles_exception
  • ✅ TestInstallFunctionAdditional::test_install_with_unsupported_type_raises_error
  • ✅ TestUninstallManifestNotFound::test_uninstall_when_manifest_not_found

Verification:
All 111 tests in the file now pass successfully.

Checks

  • make lint passes
  • make test passes

Notes (optional)

Signed-off-by: habeck <habeck@us.ibm.com>
Copy link
Copy Markdown
Contributor

@araujof araujof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@araujof araujof merged commit 162dfa0 into contextforge-org:main Jun 1, 2026
14 checks passed
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.

2 participants