Returns list of (agent_dir, test_file_path) recursively.
(
target_folder: str | None = None,
)
| 53 | |
| 54 | # Read target folder from environment |
| 55 | def get_test_files( |
| 56 | target_folder: str | None = None, |
| 57 | ) -> list[pytest.ParameterSet]: |
| 58 | """Returns list of (agent_dir, test_file_path) recursively.""" |
| 59 | folder = target_folder or os.environ.get("ADK_TEST_FOLDER") |
| 60 | if not folder: |
| 61 | return [] |
| 62 | target_dir = Path(folder) |
| 63 | if not target_dir.exists(): |
| 64 | return [] |
| 65 | |
| 66 | samples_dir = ( |
| 67 | Path(__file__).parent.parent.parent.parent.parent |
| 68 | / "contributing" |
| 69 | / "samples" |
| 70 | ) |
| 71 | |
| 72 | results = [] |
| 73 | for test_file in target_dir.rglob("tests/*.json"): |
| 74 | agent_dir = test_file.parent.parent |
| 75 | # Verify it looks like an agent directory |
| 76 | if ( |
| 77 | (agent_dir / "agent.py").exists() |
| 78 | or (agent_dir / "__init__.py").exists() |
| 79 | or (agent_dir / "root_agent.yaml").exists() |
| 80 | ): |
| 81 | try: |
| 82 | rel_dir = agent_dir.relative_to(samples_dir) |
| 83 | test_id = f"{rel_dir}/{test_file.name}" |
| 84 | except ValueError: |
| 85 | test_id = f"{agent_dir.name}/{test_file.name}" |
| 86 | |
| 87 | if test_file.stem.endswith("_xfail"): |
| 88 | results.append( |
| 89 | pytest.param( |
| 90 | agent_dir, test_file, id=test_id, marks=pytest.mark.xfail |
| 91 | ) |
| 92 | ) |
| 93 | else: |
| 94 | results.append(pytest.param(agent_dir, test_file, id=test_id)) |
| 95 | return results |
| 96 | |
| 97 | |
| 98 | class MockModel(BaseLlm): |
no test coverage detected