Skip to content

feat: use pattern-based pytest.raises(match=) in test-generation prompts (#1231) - #1235

Merged
gltanaka merged 2 commits into
mainfrom
change/issue-1231
May 28, 2026
Merged

feat: use pattern-based pytest.raises(match=) in test-generation prompts (#1231)#1235
gltanaka merged 2 commits into
mainfrom
change/issue-1231

Conversation

@prompt-driven-github

@prompt-driven-github prompt-driven-github Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Updates the test-generation prompts to require regex pattern matching (match=r"keyword1|keyword2") or type-only assertions in pytest.raises() calls instead of exact-string literals. This prevents cascading test failures when LLM regeneration rewords error messages while preserving exception type and behavior.

Closes #1231

Changes Made

Prompts Modified

  • pdd/prompts/generate_test_LLM.prompt — Added CRITICAL rule prohibiting exact-string match= arguments; requires match=r"keyword1|keyword2" patterns or type-only assertions
  • pdd/prompts/generate_test_from_example_LLM.prompt — Added the same CRITICAL rule before the context/test.prompt include

Context Updated

  • context/test.prompt — Updated SUMMARY OF GOOD PATTERNS bullet to mention pattern-based matching; added new Section 15: PYTEST.RAISES MATCH PATTERNS with explicit BAD/GOOD examples

Supporting Files

  • docs/prompting_guide.md — Minor update to align with pattern-matching guidance
  • architecture.json — Updated to reflect prompt changes

⚠️ Manual Review Required

  • docs/prompting_guide.md — diverged older mirror not in include graph — review contract-aware test generation block (item 6)

Review Checklist

  • Prompt syntax is valid
  • PDD conventions followed
  • Documentation is up to date

Next Steps After Merge

  1. Regenerate code from modified prompts in dependency order:
    No modules to sync
    
  2. Run tests to verify functionality:
    pytest -vv tests/

Created by pdd change workflow

…pts (#1231)

Update generate_test_LLM.prompt, generate_test_from_example_LLM.prompt, and
context/test.prompt to require regex patterns (match=r"keyword1|keyword2") or
type-only assertions instead of exact-string match= arguments, preventing test
failures when error messages are reworded during regeneration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update test-generation prompt to use pattern-based pytest.raises(match=) instead of exact strings

3 participants