mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
style: Sort imports and add whitespace in test_exceptions.py
This commit is contained in:
parent
e10205ff69
commit
9db6780af6
1 changed files with 12 additions and 2 deletions
|
@ -1,23 +1,28 @@
|
||||||
import pytest
|
import pytest
|
||||||
from aider.exceptions import LiteLLMExceptions, ExInfo
|
|
||||||
|
from aider.exceptions import ExInfo, LiteLLMExceptions
|
||||||
|
|
||||||
|
|
||||||
def test_litellm_exceptions_load():
|
def test_litellm_exceptions_load():
|
||||||
"""Test that LiteLLMExceptions loads without errors"""
|
"""Test that LiteLLMExceptions loads without errors"""
|
||||||
ex = LiteLLMExceptions()
|
ex = LiteLLMExceptions()
|
||||||
assert len(ex.exceptions) > 0
|
assert len(ex.exceptions) > 0
|
||||||
|
|
||||||
|
|
||||||
def test_exceptions_tuple():
|
def test_exceptions_tuple():
|
||||||
"""Test that exceptions_tuple returns a non-empty tuple"""
|
"""Test that exceptions_tuple returns a non-empty tuple"""
|
||||||
ex = LiteLLMExceptions()
|
ex = LiteLLMExceptions()
|
||||||
assert isinstance(ex.exceptions_tuple(), tuple)
|
assert isinstance(ex.exceptions_tuple(), tuple)
|
||||||
assert len(ex.exceptions_tuple()) > 0
|
assert len(ex.exceptions_tuple()) > 0
|
||||||
|
|
||||||
|
|
||||||
def test_get_ex_info():
|
def test_get_ex_info():
|
||||||
"""Test get_ex_info returns correct ExInfo"""
|
"""Test get_ex_info returns correct ExInfo"""
|
||||||
ex = LiteLLMExceptions()
|
ex = LiteLLMExceptions()
|
||||||
|
|
||||||
# Test with a known exception type
|
# Test with a known exception type
|
||||||
from litellm import AuthenticationError
|
from litellm import AuthenticationError
|
||||||
|
|
||||||
auth_error = AuthenticationError()
|
auth_error = AuthenticationError()
|
||||||
ex_info = ex.get_ex_info(auth_error)
|
ex_info = ex.get_ex_info(auth_error)
|
||||||
assert isinstance(ex_info, ExInfo)
|
assert isinstance(ex_info, ExInfo)
|
||||||
|
@ -28,6 +33,7 @@ def test_get_ex_info():
|
||||||
# Test with unknown exception type
|
# Test with unknown exception type
|
||||||
class UnknownError(Exception):
|
class UnknownError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
unknown = UnknownError()
|
unknown = UnknownError()
|
||||||
ex_info = ex.get_ex_info(unknown)
|
ex_info = ex.get_ex_info(unknown)
|
||||||
assert isinstance(ex_info, ExInfo)
|
assert isinstance(ex_info, ExInfo)
|
||||||
|
@ -35,19 +41,23 @@ def test_get_ex_info():
|
||||||
assert ex_info.retry is None
|
assert ex_info.retry is None
|
||||||
assert ex_info.description is None
|
assert ex_info.description is None
|
||||||
|
|
||||||
|
|
||||||
def test_rate_limit_error():
|
def test_rate_limit_error():
|
||||||
"""Test specific handling of RateLimitError"""
|
"""Test specific handling of RateLimitError"""
|
||||||
ex = LiteLLMExceptions()
|
ex = LiteLLMExceptions()
|
||||||
from litellm import RateLimitError
|
from litellm import RateLimitError
|
||||||
|
|
||||||
rate_error = RateLimitError()
|
rate_error = RateLimitError()
|
||||||
ex_info = ex.get_ex_info(rate_error)
|
ex_info = ex.get_ex_info(rate_error)
|
||||||
assert ex_info.retry is True
|
assert ex_info.retry is True
|
||||||
assert "rate limited" in ex_info.description.lower()
|
assert "rate limited" in ex_info.description.lower()
|
||||||
|
|
||||||
|
|
||||||
def test_context_window_error():
|
def test_context_window_error():
|
||||||
"""Test specific handling of ContextWindowExceededError"""
|
"""Test specific handling of ContextWindowExceededError"""
|
||||||
ex = LiteLLMExceptions()
|
ex = LiteLLMExceptions()
|
||||||
from litellm import ContextWindowExceededError
|
from litellm import ContextWindowExceededError
|
||||||
|
|
||||||
ctx_error = ContextWindowExceededError()
|
ctx_error = ContextWindowExceededError()
|
||||||
ex_info = ex.get_ex_info(ctx_error)
|
ex_info = ex.get_ex_info(ctx_error)
|
||||||
assert ex_info.retry is False
|
assert ex_info.retry is False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue