You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: improve test guidelines in AGENTS.md (#387)
Add explicit rules for testing public APIs only, requiring type
annotations on tests/fixtures, and keeping imports at module level.
Fix fixture reference to reflect the actual pytest_plugins layout.
Made-with: Cursor
Copy file name to clipboardExpand all lines: AGENTS.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -507,7 +507,7 @@ The following ruff linter rules are currently enabled (see [pyproject.toml](pypr
507
507
508
508
The project uses `pytest` with the following patterns:
509
509
510
-
-**Fixtures**: Shared test data and configurations in [tests/conftest.py](tests/conftest.py)
510
+
-**Fixtures**: Shared fixtures are provided via `pytest_plugins` from `data_designer.config.testing.fixtures`and `data_designer.engine.testing.fixtures`, plus local `conftest.py` files in each test directory
511
511
-**Stub configs**: YAML-based configuration stubs for testing (see `stub_data_designer_config_str` fixture)
512
512
-**Mocking**: Use `unittest.mock.patch` for external services and dependencies
513
513
-**Async support**: pytest-asyncio for async tests (`asyncio_default_fixture_loop_scope = "session"`)
@@ -516,7 +516,10 @@ The project uses `pytest` with the following patterns:
516
516
517
517
### Test Guidelines
518
518
519
-
-**Parametrize over duplicate**: Use `@pytest.mark.parametrize` instead of writing multiple test functions for variations of the same behavior
519
+
-**Test public APIs only**: Tests should exercise public interfaces, not `_`-prefixed functions or classes. If something is hard to test without reaching into private internals, consider refactoring the code to expose a public entry point
520
+
-**Type annotations required**: Test functions and fixtures must include type annotations — `-> None` for tests, typed parameters, and typed return values for fixtures
521
+
-**Imports at module level**: Follow the same import rules as production code — keep imports at the top of the file, not inside test functions
522
+
-**Parametrize over duplicate**: Use `@pytest.mark.parametrize` (with `ids=` for readable names) instead of writing multiple test functions for variations of the same behavior
520
523
-**Minimal fixtures**: Fixtures should be simple — one fixture, one responsibility, just setup with no behavior logic
521
524
-**Shared fixtures in `conftest.py`**: Place fixtures shared across a test directory in `conftest.py`
522
525
-**Mock at boundaries**: Mock external dependencies (APIs, databases, third-party services), not internal functions
@@ -530,6 +533,7 @@ from typing import Any
530
533
531
534
from data_designer.config.config_builder import DataDesignerConfigBuilder
0 commit comments