Skip to content

Share sandbox clients across e2e tests to reuse tokens - #54

Merged
cretz merged 1 commit into
mainfrom
cretz/e2e-shared-token
Dec 3, 2026
Merged

cretz merged 1 commit into
mainfrom
cretz/e2e-shared-token

Conversation

@cretz

@cretz cretz commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

🚀 What

  • Share one sync and one async sandbox client across sandbox e2e tests, so a run mints about 7 tokens instead of about 90 and stays under the token endpoint's rate limit

💻 How

  • Session-scoped sync_client and async_client fixtures; client picks one, and the shared sandbox is created and deleted with the sync one
  • sandbox fixture builds from the shared record with get(info=...), dropping a get_sandbox call per test
  • pytest-asyncio test and fixture loop scope set to session in pyproject.toml, so the shared async client works in every test

🔬 Testing

  • Unit tests, lint, and typecheck pass locally; e2e runs in CI

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the changes to reuse sandbox test clients and session-scoped event loops.

No open issues 🎉

What changed in this PR

Reduces token requests in sandbox end-to-end tests by reusing clients across the test session, helping avoid token endpoint rate limits.

Changes:

  • Shares one synchronous and one asynchronous sandbox client across tests.
  • Builds sandbox handles from existing records, avoiding redundant API requests.
  • Uses session-scoped event loops for async tests and fixtures.
File Description
tests/​sandbox/​test_e2e.py Shares clients and reuses sandbox records while preserving cleanup.
pyproject.toml Sets async test and fixture event-loop scopes to session.

Review effort: Balanced

@cretz
cretz requested a review from rdingwall December 3, 2026 16:07
@cretz cretz mentioned this pull request Dec 3, 2026
@cretz
cretz merged commit ba1c948 into main Dec 3, 2026
11 of 14 checks passed
@cretz
cretz deleted the cretz/e2e-shared-token branch December 3, 2026 16:24
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.

3 participants