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
Copy file name to clipboardExpand all lines: AGENTS.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,12 @@ The project uses extremely strict mypy settings including `disallow_any_expr=tru
49
49
**Testing Requirements:**
50
50
All changes must maintain 100% branch coverage. Test both runtime and compiled behavior, plus async and thread-safe variants where applicable. Use descriptive test names: `test_<feature>_<scenario>_<expected_behavior>()`.
51
51
52
+
**Testing Conventions:**
53
+
-**Compiled Objects**: Use `wired = execd["compiled"]` from `exec(code, execd)`. Do not instantiate `Compiled` manually.
54
+
-**Type Safety**: Use `typing.Protocol` for dynamic/compiled objects. Avoid `Any` and `type: ignore`.
55
+
-**Module Mocking**: Use `sys.modules` injection with `try...finally` cleanup for custom classes.
56
+
-**Async Tests**: Use `asyncio.run()` explicitly within test functions.
57
+
52
58
**Common Gotchas:**
53
59
- SPDX headers required on all files (run `make format` to auto-add)
Copy file name to clipboardExpand all lines: docs/development.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,32 @@ pytest -xvs
49
49
50
50
The project enforces 95% test coverage or higher. New code should include comprehensive tests.
51
51
52
+
#### Testing Conventions
53
+
54
+
-**Compiled Code Testing**: When testing compiled code, use the pre-instantiated `compiled` object from the execution namespace instead of manually instantiating the class.
55
+
```python
56
+
exec(code, execd)
57
+
wired = execd["compiled"] # Use this instance
58
+
```
59
+
-**Type Safety in Tests**: Avoid `Any` and `type: ignore`. Use `typing.Protocol` to define the expected interface of dynamic or compiled objects.
60
+
```python
61
+
classMockConfig(Protocol):
62
+
defconfig(self) -> Config: ...
63
+
64
+
execd: dict[str, MockConfig] = {}
65
+
```
66
+
-**Coverage**: Aim for 100% branch coverage.
67
+
-**Naming**: Use descriptive test names: `test_<feature>_<scenario>_<expected_behavior>()`.
68
+
-**Module Mocking**: When testing custom classes, inject them into `sys.modules` using a `try...finally` block to ensure cleanup.
69
+
```python
70
+
classMockModule(ModuleType): ...
71
+
sys.modules["mymod"] = MockModule()
72
+
try:
73
+
# test code
74
+
finally:
75
+
del sys.modules["mymod"]
76
+
```
77
+
52
78
### Code Formatting
53
79
54
80
The project uses `black` and `isort` for code formatting:
0 commit comments