From 3ad1aa4299a7a97f6130d7456806ac90c53fe162 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 9 Jul 2026 12:42:20 +0200 Subject: [PATCH] AGENTS: Add layout instructions for test subdirectories Instruct agents on how to split tests into multiple files when source files ship many types or functions and the tests would grow too big. Signed-off-by: Leandro Lucarella --- tests/AGENTS.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/AGENTS.md b/tests/AGENTS.md index f5c456c8..c924c506 100644 --- a/tests/AGENTS.md +++ b/tests/AGENTS.md @@ -5,19 +5,34 @@ Tests verify that the idiomatic wrappers stay in lock-step with the generated ## LAYOUT -Tests mirror the package tree with the `src/frequenz/client/common/` prefix stripped, the -leading underscore dropped, and `test_` prepended: +Tests mirror the package tree with the `src/frequenz/client/common/` prefix stripped. +Normally a 1-1 file mapping with the leading underscore dropped, and `test_` prepended: ``` src/frequenz/client/common//_yyy.py -> tests//test_yyy.py ``` +If a src file contains multiple types and the resulting test file will become large, +split in multiple files in a subdirectory: + +``` +src/frequenz/client/common//_yyy.py -> tests//_yyy/test_xxx.py +``` + +Where `xxx` is usually one type or one function in `_yyy.py`. + Examples: -- `src/.../types/_location.py` -> `tests/types/test_location.py` -- `src/.../metrics/proto/v1alpha8/_metric.py` -> `tests/metrics/proto/v1alpha8/test_metric.py` +- `src/.../types/_location.py`: `tests/types/_location/test_location.py`, + `tests/types/_location/test_invalid_latitude.py`, etc. +- `src/.../grid/_delivery_area.py`: `tests/grid/test_delivery_area.py` +- `src/.../metrics/proto/v1alpha8/_metric.py`: `tests/metrics/proto/v1alpha8/test_metric.py` Keep the `proto//` nesting intact (currently only `v1alpha8`). +Avoid repeating prefixes in files and test names. For example: +- `src/.../types/_location/test_location.py`: `test_construction()`, + NOT `test_location_construction()` + ## ENUM TESTS = ONE-LINE SUBCLASS Never re-scaffold enum/proto checks. Subclass