Skip to content

Skip API tests when fastapi is not installed#1

Merged
hoodchris merged 1 commit intomainfrom
claude/add-test-coverage-QMVU9
Mar 16, 2026
Merged

Skip API tests when fastapi is not installed#1
hoodchris merged 1 commit intomainfrom
claude/add-test-coverage-QMVU9

Conversation

@hoodchris
Copy link
Contributor

@hoodchris hoodchris commented Mar 16, 2026

Summary

Updated the test suite to gracefully skip API tests when the optional fastapi dependency is not installed, rather than failing with an import error.

Key Changes

  • Added pytest.importorskip() call for the fastapi module before importing from it
  • This allows the test file to be collected and skipped with a clear reason message when fastapi is not available
  • Users installing without the [api] extra will no longer see test failures for missing optional dependencies

Implementation Details

The pytest.importorskip() function is used to conditionally skip the entire test module if fastapi is not installed. The skip message directs users to install the package with the [api] extra: pip install agentpk[api]. This is a best practice for handling optional test dependencies in pytest.

fastapi is an optional dependency (agentpk[api]), so test_api.py should
gracefully skip instead of failing with an ImportError during collection.

https://claude.ai/code/session_01TxNcxsPV2QXDc71e15dLV1
@hoodchris hoodchris merged commit f2ba17a into main Mar 16, 2026
7 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