Skip to content

fix: correct mock targets in LocalEvalSetsManager tests#4373

Open
G26karthik wants to merge 7 commits intogoogle:mainfrom
G26karthik:fix/eval-sets-manager-test-mocks
Open

fix: correct mock targets in LocalEvalSetsManager tests#4373
G26karthik wants to merge 7 commits intogoogle:mainfrom
G26karthik:fix/eval-sets-manager-test-mocks

Conversation

@G26karthik
Copy link

Summary

Fixes 2 failing unit tests in test_local_eval_sets_manager.py that were incorrectly mocking get_eval_case instead of get_eval_set.

Problem

The following tests were failing with OSError: [Errno 22] Invalid argument:

  • test_local_eval_sets_manager_update_eval_case_eval_set_not_found
  • test_local_eval_sets_manager_delete_eval_case_eval_set_not_found

Root Cause

Both update_eval_case() and delete_eval_case() call get_eval_set_from_app_and_id() first, which internally calls get_eval_set(). The tests were mocking get_eval_case instead of get_eval_set, so the code path hit the actual file system.

The error message showed an invalid path like:

'<tests.unittests.evaluation.test_local_eval_sets_manager.TestLocalEvalSetsManager object at 0x...>\\test_app\\test_eval_set.evalset.json'

This happened because the class fixture was receiving self as the first parameter instead of tmp_path.

Fix

Changed the mock target from get_eval_case to get_eval_set with return_value=None, which correctly triggers the NotFoundError for "eval set not found" scenarios via get_eval_set_from_app_and_id().

Before

mocker.patch(
    "google.adk.evaluation.local_eval_sets_manager.LocalEvalSetsManager.get_eval_case",
    return_value=None,
)

After

mocker.patch(
    "google.adk.evaluation.local_eval_sets_manager.LocalEvalSetsManager.get_eval_set",
    return_value=None,
)

Testing

All 29 tests in test_local_eval_sets_manager.py now pass:

============================= 29 passed in 4.03s ==============================

G26karthik and others added 7 commits November 12, 2025 05:30
Enhanced the LLM-as-judge prompt to explicitly handle non-English languages including Chinese, Thai, Japanese, Korean, Arabic, Hebrew, Hindi, and other non-Latin scripts.

The evaluator now:
- Recognizes identical strings in any language as valid matches
- Handles Unicode and character encoding differences
- Accepts language-specific punctuation variations (e.g., 。 vs . in Chinese)
- Treats all languages with equal evaluation standards

Fixes google#3111
Fixes google#3162
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Two tests were incorrectly mocking get_eval_case instead of get_eval_set:
- test_local_eval_sets_manager_update_eval_case_eval_set_not_found
- test_local_eval_sets_manager_delete_eval_case_eval_set_not_found

The code path calls get_eval_set first via get_eval_set_from_app_and_id(),
so these tests need to mock get_eval_set to return None to trigger the
NotFoundError for eval set not found scenarios.

This fixes the OSError that occurred when the actual file system was hit
with an invalid path due to the fixture parameter issue.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @G26karthik, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where two unit tests in LocalEvalSetsManager were failing due to an incorrect mocking strategy. By adjusting the mock target from get_eval_case to get_eval_set, the tests now correctly simulate the scenario where an evaluation set is not found, preventing unintended file system interactions and ensuring the robustness of the test suite.

Highlights

  • Test Fix: Corrected two failing unit tests in test_local_eval_sets_manager.py that were encountering OSError: [Errno 22] Invalid argument.
  • Mocking Correction: Changed the mock target from get_eval_case to get_eval_set in specific test cases to accurately simulate NotFoundError when an eval set is not found.
  • Test Stability: Ensured all 29 tests in the test_local_eval_sets_manager.py module now pass consistently.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tests/unittests/evaluation/test_local_eval_sets_manager.py
    • Updated the mocker.patch call in test_local_eval_sets_manager_update_eval_case_eval_set_not_found to mock get_eval_set instead of get_eval_case.
    • Updated the mocker.patch call in test_local_eval_sets_manager_delete_eval_case_eval_set_not_found to mock get_eval_set instead of get_eval_case.
Activity
  • The author identified and fixed two failing unit tests.
  • All 29 tests in test_local_eval_sets_manager.py are now passing after the changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes two failing unit tests in test_local_eval_sets_manager.py. The tests for update_eval_case and delete_eval_case were incorrectly mocking get_eval_case instead of get_eval_set for 'eval set not found' scenarios. The change correctly updates the mock target, which resolves the test failures. The fix is accurate and the reasoning is well-documented in the pull request description. The changes look good.

@adk-bot adk-bot added the eval [Component] This issue is related to evaluation label Feb 5, 2026
@adk-bot
Copy link
Collaborator

adk-bot commented Feb 5, 2026

Response from ADK Triaging Agent

Hello @G26karthik, thank you for creating this PR!

This PR is a bug fix. Could you please associate a GitHub issue with this PR? If there is no existing issue, could you please create one?

This information will help reviewers to review your PR more efficiently. Thanks!

@G26karthik
Copy link
Author

Created issue #4374 to track this bug.

This PR fixes the issue by changing the mock target from get_eval_case to get_eval_set in the two failing tests.

@G26karthik
Copy link
Author

/gemini Now Is this PR Good to go to Maintainers

@gemini-code-assist
Copy link
Contributor

Hello @G26karthik,

Based on my review, this PR looks good to go! The changes effectively address the identified issue by correcting the mock targets in the LocalEvalSetsManager tests, which has resolved the OSError: [Errno 22] Invalid argument and ensures all 29 tests now pass consistently.

This is a clear and targeted fix that improves the stability and correctness of the test suite. Well done on identifying and resolving the root cause!

Feel free to proceed with merging this PR when you're ready.

@G26karthik
Copy link
Author

G26karthik commented Feb 5, 2026

Hi @precision @AustinWise @rspier - minimal fix, all 29 tests now passing. Ready for review. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval [Component] This issue is related to evaluation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants