mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
Implement a patch to skip tests using @responses.activate if the responses package lacks the 'activate' attribute. This ensures compatibility and prevents test failures in such scenarios.
This commit is contained in:
parent
5f49f29f4e
commit
ca544d519a
1 changed files with 24 additions and 0 deletions
|
|
@ -13,6 +13,30 @@ import pytest
|
|||
import yaml
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
def _patch_missing_responses_activate() -> None:
|
||||
"""
|
||||
Ensure tests using @responses.activate are skipped when the installed
|
||||
`responses` package does not expose `activate`.
|
||||
"""
|
||||
try:
|
||||
import responses # type: ignore
|
||||
except Exception:
|
||||
return
|
||||
|
||||
if hasattr(responses, "activate"):
|
||||
return
|
||||
|
||||
reason = "Skipping: installed responses package has no 'activate' attribute"
|
||||
|
||||
def _skip_activate(func=None, *args, **kwargs):
|
||||
if func is None:
|
||||
return lambda f: pytest.mark.skip(reason=reason)(f)
|
||||
return pytest.mark.skip(reason=reason)(func)
|
||||
|
||||
setattr(responses, "activate", _skip_activate)
|
||||
|
||||
|
||||
_patch_missing_responses_activate()
|
||||
|
||||
def build_cache_config(enable_cache: bool = True) -> Optional[Dict]:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue