Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tests: add async timeout/retry coverage and clarify per-request overrides #2595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lucasalencarxisto-stack wants to merge 1 commit into openai:main
base: main
Choose a base branch
Loading
from lucasalencarxisto-stack:tests/async-timeouts-retries

Conversation

Copy link

@lucasalencarxisto-stack lucasalencarxisto-stack commented Aug 31, 2025
edited
Loading

Note: This PR overlaps with #2615 / #2616.
If those land first, I’m happy to close this one.
The goal here is simply to improve async timeout/retry coverage and clarify per-request overrides.

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.

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
Reviewers
1 more reviewer

@OscaeGTX OscaeGTX OscaeGTX approved these changes

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /