Testing Guidelines
Rules for writing tests in dimos. These address recurring issues found in code review. For grid testing (spec/impl tests across multiple backends), see Grid Testing Strategy.Imports at the top
All imports must be at module level, not inside test functions.Always clean up resources
Use context managers or try/finally. If a test creates a resource, it must be cleaned up even if assertions fail.yield instead of repeating context managers in each test:
No conditional logic in assertions
Tests must be deterministic. If you don’t know the state, the test is wrong.skip
Print statements
- Unit tests: no prints. Use assertions.
tool_*.pyfiles (integration/exploration tools): prints are fine for progress and inspection output.
Avoid unnecessary sleeps
Don’t usetime.sleep() to wait for async operations. Use threading.Event to synchronize emitter/receiver patterns.
skip
Private fields
Configuration fields on non-Pydantic classes should be private (underscore-prefixed) unless they are part of the public API.skip
Type ignores
Avoid# type: ignore by using proper types:
skip
open3d) or decorator-generated attributes (e.g. @simple_mcache adding invalidate_cache).