Skip to content

Conversation

lucasalencarxisto-stack

…sertions

Summary

This PR improves the test suite for timeouts and retries by adding clearer
async coverage and detailed assertions for per-request overrides.

Changes

  • Added test_timeouts_async.py with:
    • Verification that per-request timeout overrides the client default.
    • Inverse scenario where smaller per-request timeout triggers TimeoutException.
    • Normalization helper to handle float, dict, or httpx.Timeout.
  • Enhanced comments/docstrings across test_timeouts.py and test_retries.py.
  • Patched OPENAI_API_KEY with a dummy value during tests.

Why

  • Prevent regressions in timeout handling between sync/async clients.
  • Ensure correct behavior when Retry-After headers are present (sync + async).
  • Make tests easier to maintain by documenting intent and expected flow.

Notes

  • Avoided UnboundLocalError in async handlers by removing inline type hints.
  • Test names and comments follow a given / when / then style for clarity.

@lucasalencarxisto-stack lucasalencarxisto-stack requested a review from a team as a code owner August 31, 2025 15:13
@lucasalencarxisto-stack
Copy link
Author

Hi team 👋

This PR addresses a test issue I encountered while working with timeouts/retries:

  • Fixed UnboundLocalError in async timeout tests by removing inline type hints and ensuring httpx is imported only at the top level.
  • Added explicit async coverage to confirm per-request timeouts override client defaults, and that smaller per-request values properly raise TimeoutException.
  • Improved retry tests with clearer comments and docstrings, especially around handling Retry-After headers and server error retries.

The main goal is to make timeout/retry behavior more robust against regressions and easier to understand for future contributors.

Happy to adjust anything if needed 🙏

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.

1 participant