Context
When adding validated_get and ensure_get methods to KeyValueFileManager, the tests for these methods were placed in tests/usethis/_file/test_validate.py instead of tests/usethis/_file/test_manager.py.
Root Cause
The tests were written near the validate_or_raise/validate_or_default tests since they use similar validation functionality. However, these methods are defined on KeyValueFileManager (in manager.py), not in validate.py.
Principle
Tests for a class method should live in the test file for that class, not in the test file for the utilities the method uses internally. The test file structure should mirror the source file structure. If a method is defined on KeyValueFileManager in manager.py, its tests belong under TestKeyValueFileManager in test_manager.py.
Affected Skills
The usethis-python-test skill should include guidance on test placement: always match test class structure to the source class hierarchy.
Context
When adding
validated_getandensure_getmethods toKeyValueFileManager, the tests for these methods were placed intests/usethis/_file/test_validate.pyinstead oftests/usethis/_file/test_manager.py.Root Cause
The tests were written near the
validate_or_raise/validate_or_defaulttests since they use similar validation functionality. However, these methods are defined onKeyValueFileManager(inmanager.py), not invalidate.py.Principle
Tests for a class method should live in the test file for that class, not in the test file for the utilities the method uses internally. The test file structure should mirror the source file structure. If a method is defined on
KeyValueFileManagerinmanager.py, its tests belong underTestKeyValueFileManagerintest_manager.py.Affected Skills
The
usethis-python-testskill should include guidance on test placement: always match test class structure to the source class hierarchy.