Skip to content

Add failing tests for #412: incorrect sys.modules paths#434

Draft
prompt-driven-github[bot] wants to merge 1 commit intomainfrom
fix/issue-412
Draft

Add failing tests for #412: incorrect sys.modules paths#434
prompt-driven-github[bot] wants to merge 1 commit intomainfrom
fix/issue-412

Conversation

@prompt-driven-github
Copy link
Contributor

Summary

Adds failing tests that detect the bug reported in #412, where PDD generates tests with incorrect sys.modules paths that don't match actual import statements in source code.

Test Files

  • Unit test: tests/test_e2e_issue_412_sys_modules_paths.py
  • E2E test: tests/test_e2e_issue_412_cli_sys_modules_paths.py

What This PR Contains

  • Failing unit test that reproduces the reported bug by validating that generated sys.modules keys match actual import paths from source code
  • Failing E2E test that verifies the bug at integration level, exercising the full PDD CLI workflow with realistic project structures
  • Tests are verified to fail on current code and will pass once the bug is fixed

Root Cause

PDD does not extract actual import statements from source code before generating tests. It only passes the filename stem (e.g., "firestore_client") as module_name to the LLM at pdd/cmd_test_main.py:193, forcing the LLM to guess which module paths need mocking in sys.modules. This results in inconsistent inference where sometimes sys.modules["config"] is generated (wrong) when the source uses from src.config import ..., and sometimes sys.modules["src.config"] is generated (correct).

Next Steps

  1. Implement the fix at pdd/cmd_test_main.py to extract actual import paths using Python's ast module
  2. Verify the unit test passes
  3. Verify the E2E test passes
  4. Run full test suite
  5. Mark PR as ready for review

Fixes #412


Generated by PDD agentic bug workflow

This commit adds two comprehensive test files that detect the bug where
PDD generates tests with incorrect sys.modules paths that don't match
actual import statements in source code.

Test files:
- tests/test_e2e_issue_412_sys_modules_paths.py: Unit tests validating
  that generated sys.modules keys match actual import paths
- tests/test_e2e_issue_412_cli_sys_modules_paths.py: E2E tests exercising
  the full PDD CLI workflow with realistic project structures

All tests fail as expected, successfully reproducing the bug reported in #412.

Co-Authored-By: Claude Sonnet 4.5 <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.

Generated tests use incorrect sys.modules paths for mocking

1 participant