Skip to content

[AAASM-4263] 🚨 (tests): Fix pytest.raises block scope violations#225

Merged
Chisanan232 merged 6 commits into
masterfrom
v0.0.1/224/fix/pytest_raises_cleanup
Jul 7, 2026
Merged

[AAASM-4263] 🚨 (tests): Fix pytest.raises block scope violations#225
Chisanan232 merged 6 commits into
masterfrom
v0.0.1/224/fix/pytest_raises_cleanup

Conversation

@Chisanan232

Copy link
Copy Markdown
Contributor

Summary

  • Extract setup calls (variable assignments) outside pytest.raises() blocks across 6 test files
  • Ensures only the method under test can throw the expected exception
  • Resolves SonarCloud rule python:S5778 for cleaner, more precise exception testing

Test plan

  • Verify all tests still pass: pytest python/*/tests/test_smoke.py
  • Confirm SonarCloud no longer reports S5778 violations on these files

Closes #224

🤖 Generated with Claude Code

Chisanan232 and others added 6 commits July 7, 2026 10:25
…ramework

Move args assignment outside pytest.raises() block to ensure only
the invoke method under test can throw the expected exception.

Resolves SonarCloud rule python:S5778.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move ctx assignment outside pytest.raises() block to ensure only
the run_async method under test can throw the expected exception.

Resolves SonarCloud rule python:S5778.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move run_id assignment outside pytest.raises() block to ensure only
the on_tool_start method under test can throw the expected exception.

Resolves SonarCloud rule python:S5778.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…h Agent

Move run_id assignment outside pytest.raises() block to ensure only
the on_tool_start method under test can throw the expected exception.

Resolves SonarCloud rule python:S5778.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move run_id assignment outside pytest.raises() block to ensure only
the on_tool_start method under test can throw the expected exception.

Resolves SonarCloud rule python:S5778.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…gent

Move run_id assignment outside pytest.raises() block to ensure only
the on_tool_start method under test can throw the expected exception.

Resolves SonarCloud rule python:S5778.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

@Chisanan232

Copy link
Copy Markdown
Contributor Author

Claude Code Review

CI Status

✅ All CI checks passed (22/22 SUCCESS)

Scope Coverage Review

Task Status
Fix S5778 in microsoft-agent-framework tests ✅ Completed
Fix S5778 in google-adk tests ✅ Completed
Fix S5778 in langgraph tests ✅ Completed
Fix S5778 in langchain-research-agent tests ✅ Completed
Fix S5778 in openai-agents-sdk tests ✅ Completed
Fix S5778 in langchain-basic-agent tests ✅ Completed

Side Effect Analysis

  • No side effects: Test-only changes
  • Extracted setup calls (uuid4(), _tool_context(), tool_arguments()) are assigned before pytest.raises() blocks
  • Test behavior unchanged — only ensures single throwing call inside pytest.raises()
  • All Python example verification checks pass

Recommendation

Ready for merge - meets all acceptance criteria


🤖 Reviewed by Claude Code

@Chisanan232 Chisanan232 changed the title [#224] 🐛 (test): Fix pytest.raises multiple throwing calls [AAASM-4263] 🚨 (tests): Fix pytest.raises block scope violations Jul 7, 2026
@Chisanan232 Chisanan232 merged commit f52a0bb into master Jul 7, 2026
22 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/224/fix/pytest_raises_cleanup branch July 7, 2026 05:17
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.

[SonarCloud] Fix pytest.raises code quality issues

1 participant