Skip to content

Commit de37849

Browse files
emcdclaude
andcommitted
Enhance write-tests command and testing guidelines based on AAR feedback.
Command improvements: - Add WebFetch to allowed tools for guide access - Add mandatory pre-flight check to verify guide accessibility - Add step to check for existing tests to avoid duplication - Add tests/README.md generation when missing - Add final report requirement for technical conflicts and resolutions Testing guide enhancement: - Add cross-platform testing strategy using pathlib.Path.resolve() and .samefile() for Windows compatibility These changes address gaps identified in first trial run where test guide wasn't properly accessed and platform-specific issues weren't considered. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0344584 commit de37849

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

documentation/common/tests.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ Testing Strategy by Code Type
244244
* - **Abstract Methods**
245245
- ``# pragma: no cover``
246246
- Apply to ``NotImplementedError`` lines only
247+
* - **Cross-Platform**
248+
- ``pathlib.Path`` with ``.resolve()`` and ``.samefile()``
249+
- Use ``Path.resolve()`` to unfurl symlinks; ``.samefile()`` for comparisons on Windows
247250

248251
Development Environment
249252
===============================================================================

template/.auxiliary/configuration/claude/commands/write-tests.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
allowed-tools: Bash(hatch --env develop run:*), Bash(git status), Bash(git log:*), Bash(echo:*), Bash(ls:*), Bash(find:*), LS, Read, Glob, Grep, Write, Edit, MultiEdit
2+
allowed-tools: Bash(hatch --env develop run:*), Bash(git status), Bash(git log:*), Bash(echo:*), Bash(ls:*), Bash(find:*), LS, Read, Glob, Grep, Write, Edit, MultiEdit, WebFetch
33
description: Write comprehensive tests following project testing guidelines and improve coverage
44
---
55

@@ -79,9 +79,24 @@ following occur:
7979

8080
Execute the following steps for test requirements: `$ARGUMENTS`
8181

82+
### 0. Pre-Flight Verification
83+
**MANDATORY - Verify access to test-writing guide:**
84+
85+
Use WebFetch to access and confirm you can read the complete testing guidelines:
86+
```
87+
https://raw.githubusercontent.com/emcd/python-project-common/refs/heads/master/documentation/common/tests.rst
88+
```
89+
90+
**CRITICAL**: You MUST successfully access and read the guide before proceeding. If WebFetch fails, HALT and consult with the user.
91+
8292
### 1. Code Analysis Phase
8393
Examine the target code to understand testing needs:
8494

95+
**Check for existing related tests to avoid duplication:**
96+
- Search for existing test files covering target modules
97+
- Review test coverage reports for current state
98+
- Identify gaps rather than recreating existing tests
99+
85100
**For each target file:**
86101
- Read the source code to understand public API
87102
- Identify functions/classes that need testing
@@ -93,6 +108,11 @@ Determine appropriate test organization and categories:
93108

94109
**Review existing test structure and plan test numbering following project conventions.**
95110

111+
**If tests/README.md is missing, create it with:**
112+
- Test module numbering scheme specific to the package
113+
- Rationale for any use of patch or other exceptions to standard patterns
114+
- Project-specific testing conventions and fixtures
115+
96116
**Test Categories to Include:**
97117
- **Basic Functionality Tests (000-099):** Happy path scenarios, input validation, basic error conditions
98118
- **Feature-Specific Tests (100+ blocks):** Each public function/class gets its own 100-block with normal usage patterns, edge cases, and error handling
@@ -180,3 +200,12 @@ Tests are complete when:
180200

181201
**Note**: Always run full validation (`hatch --env develop run testers && hatch
182202
--env develop run linters`) before considering the task complete.
203+
204+
## Final Report
205+
206+
Upon completion, provide a brief report covering:
207+
- Coverage improvements achieved (before/after percentages)
208+
- Any technical conflicts encountered (e.g., dataclass/protocol issues, __slots__ conflicts)
209+
- How any conflicts were resolved or worked around
210+
- Pragma directives applied (# pragma: no cover, # pragma: no branch) and rationale
211+
- Any deviations from standard patterns and justification

0 commit comments

Comments
 (0)