Skip to content

[codex] Isolate apps review validation imports#7943

Open
tianmind-studio wants to merge 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/windows-apps-review-multipart-stub
Open

[codex] Isolate apps review validation imports#7943
tianmind-studio wants to merge 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/windows-apps-review-multipart-stub

Conversation

@tianmind-studio

Copy link
Copy Markdown
Contributor

Summary

  • Temporarily stub python_multipart while importing routers.apps in test_apps_review_reply_validation.py so the test can collect in lightweight Windows backend environments without the full multipart package installed.
  • Snapshot and restore pre-existing stubbed modules around the heavy router import instead of clearing all matching sys.modules entries globally.
  • Keep the test focused on reply_to_review validation while avoiding cross-test collection pollution.

Root cause

routers.apps defines Form / File endpoints at import time. FastAPI validates that python-multipart is installed while building those routes, so this lightweight Windows backend venv failed before the review-reply assertions could collect:

RuntimeError: Form data requires "python-multipart" to be installed.

After fixing that collection issue, running this file with another stub-heavy test exposed an existing cleanup problem: the test removed stubs installed by other collected test modules. Restoring a snapshot keeps the import isolation local to this file.

Validation

  • python -m pytest backend/tests/unit/test_apps_review_reply_validation.py --collect-only -q --tb=short -> 4 tests collected
  • python -m pytest backend/tests/unit/test_apps_review_reply_validation.py -q --tb=short -> 4 passed
  • python -m pytest backend/tests/unit/test_action_item_date_validation.py backend/tests/unit/test_apps_review_reply_validation.py -q --tb=short -> 30 passed
  • python -m pytest backend/tests/unit/test_apps_review_reply_validation.py backend/tests/unit/test_action_item_date_validation.py -q --tb=short -> 30 passed
  • black --line-length 120 --skip-string-normalization backend/tests/unit/test_apps_review_reply_validation.py
  • python -m py_compile backend/tests/unit/test_apps_review_reply_validation.py
  • git diff --check
  • scripts/pre-commit

Temporarily stub python_multipart while importing the apps router in the review-reply validation test.

Restore pre-existing stubbed modules after import so this test does not remove stubs installed by other unit tests during collection.
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.

1 participant