MCPcopy Index your code
hub / github.com/google/adk-python / cli_test

Function cli_test

src/google/adk/cli/cli_tools_click.py:824–888  ·  view source on GitHub ↗

Runs pytest on agent test JSON files under the specified folder. FOLDER: The path to the folder containing agents and tests. Defaults to the current directory if not specified. Example: adk test path/to/agents

(ctx, folder: str, rebuild: bool)

Source from the content-addressed store, hash-verified

822)
823@click.pass_context
824def cli_test(ctx, folder: str, rebuild: bool):
825 """Runs pytest on agent test JSON files under the specified folder.
826
827 FOLDER: The path to the folder containing agents and tests.
828 Defaults to the current directory if not specified.
829
830 Example:
831 adk test path/to/agents
832 """
833 import sys
834
835 if rebuild:
836 from .agent_test_runner import rebuild_tests
837
838 click.echo(f"Rebuilding tests in {folder}...")
839 rebuild_tests(folder)
840 sys.exit(0)
841
842 # Parse arguments to separate pytest args (after --) from regular args
843 pytest_args = []
844 if "--" in ctx.args:
845 separator_index = ctx.args.index("--")
846 pytest_args = ctx.args[separator_index + 1 :]
847 regular_args = ctx.args[:separator_index]
848
849 if regular_args:
850 click.secho(
851 "Error: Unexpected arguments after folder and before '--':"
852 f" {' '.join(regular_args)}. \nOnly arguments after '--' are passed"
853 " to pytest.",
854 fg="red",
855 err=True,
856 )
857 ctx.exit(2)
858 else:
859 # If no '--', all remaining arguments are passed to pytest
860 pytest_args = ctx.args
861
862 import subprocess
863
864 os.environ["ADK_TEST_FOLDER"] = folder
865
866 current_dir = Path(__file__).parent
867 test_runner_path = current_dir / "agent_test_runner.py"
868
869 if not test_runner_path.exists():
870 click.secho(
871 f"Error: Test runner not found at {test_runner_path}",
872 fg="red",
873 err=True,
874 )
875 sys.exit(1)
876
877 click.echo(f"Running tests in {folder} using runner {test_runner_path}...")
878
879 result = subprocess.run([
880 sys.executable,
881 "-m",

Callers

nothing calls this directly

Calls 5

rebuild_testsFunction · 0.85
exitMethod · 0.80
joinMethod · 0.45
existsMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected