Skip to content

test(tools): run wait async tests with anyio (#7305) - #7307

Closed
liang0417 wants to merge 2 commits into
crewAIInc:mainfrom
liang0417:test/wait-tool-anyio
Closed

test(tools): run wait async tests with anyio (#7305)#7307
liang0417 wants to merge 2 commits into
crewAIInc:mainfrom
liang0417:test/wait-tool-anyio

Conversation

@liang0417

@liang0417 liang0417 commented Sep 7, 2026

Copy link
Copy Markdown

Related issue

Fixes #7305

Summary

  • run the two asynchronous WaitTool tests with the AnyIO pytest plugin
  • pin the AnyIO backend to asyncio because WaitTool.arun() uses asyncio.sleep
  • allow only the IPv4 loopback address so the asyncio event loop can initialize on Windows while the repository-wide network block remains active

Verification

  • Tests added or updated for the changed behavior
  • Relevant tests and quality checks pass locally

Commands:

  • uv run pytest --override-ini "addopts=" --disable-plugin-autoload -p anyio.pytest_plugin -p pytest_recording.plugin lib/crewai-tools/tests/tools/wait_tool_test.py -q (23 passed)
  • uv run pytest lib/crewai-tools/tests/tools/wait_tool_test.py -q (23 passed)
  • uv run ruff check --isolated lib/crewai-tools/tests/tools/wait_tool_test.py
  • uv run ruff format --check --isolated lib/crewai-tools/tests/tools/wait_tool_test.py

Additional context

This is an AI-assisted contribution. I attempted to apply the required llm-generated label, but GitHub does not grant external contributors permission to add labels in the upstream repository. Maintainers: please apply llm-generated during triage.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 48de76db-b2d1-4fba-8681-f1ddf3a54413

📥 Commits

Reviewing files that changed from the base of the PR and between 193a166 and a3cfdd7.

📒 Files selected for processing (1)
  • lib/crewai-tools/tests/tools/wait_tool_test.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The wait tool tests now use AnyIO with an asyncio backend. Both async tests allow localhost network access and replace the pytest.mark.asyncio marker with pytest.mark.anyio.

Changes

Wait tool test execution

Layer / File(s) Summary
Configure AnyIO async tests
lib/crewai-tools/tests/tools/wait_tool_test.py
The test module adds an anyio_backend fixture that returns "asyncio". Both async tests use pytest.mark.anyio and allow localhost network access.

Merge Risk: ⚪ Minimal · up to 881fb

The asynchronous WaitTool tests now run through AnyIO using the asyncio backend, with loopback access allowed for Windows event-loop initialization. This is test-only configuration and presents no remaining merge-blocking product risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #7305 by configuring the two asynchronous WaitTool tests to run with AnyIO, pinning the asyncio backend, and allowing IPv4 loopback access required for event-loop initializat…
Out of Scope Changes check ✅ Passed The changes are limited to the relevant WaitTool test file and directly support the linked issue objectives. No unrelated changes are present.
Title check ✅ Passed The title clearly and concisely describes the main change: updating WaitTool asynchronous tests to run with the AnyIO pytest plugin.
Description check ✅ Passed The description includes the related issue, a clear summary, verification steps with passing results, and additional context. It satisfies the repository template.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@liang0417

Copy link
Copy Markdown
Author

Disclosure: this is an AI-assisted contribution. I attempted to add the required llm-generated label, but GitHub returned a permissions error for this external contributor account. Could a maintainer please apply the label during triage?

@liang0417
liang0417 force-pushed the test/wait-tool-anyio branch from a3cfdd7 to b0746c0 Compare September 7, 2026 09:05
@Vidit-Ostwal

Copy link
Copy Markdown
Contributor

This isn't the right fix for #7305. Switching two tests to @pytest.mark.anyio makes the reported anyio-only invocation pass and the repo's pytest-asyncio invocation fail. The rest of the suite (including snowflake_search_tool_test.py) stays on pytest-asyncio; we are not moving off that plugin.

The right downstream command is -p pytest_asyncio, not a one-off mark swap. Closing with #7305.

@liang0417

Copy link
Copy Markdown
Author

Thanks for the careful review and for clarifying that CrewAI’s test suite remains on pytest-asyncio. I appreciate the concrete direction.
I traced the failing invocation to the downstream FreeBSD port and submitted freebsd/freebsd-ports#615 to replace the AnyIO test dependency with pytest-asyncio and explicitly load pytest_asyncio.plugin when plugin autoload is disabled. The focused WaitTool tests pass 23/23 with that setup.
Thanks again — your feedback helped me move the fix to the correct layer.

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.

[BUG] 2 Tests fail when pytest is run with --disable-plugin-autoload -p anyio

2 participants