fix: use threading instead of subprocess for Windows provider tests (#639)#1328
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes Windows CI failures by refactoring the Flask provider server startup mechanism from subprocess to threading. The change addresses platform-specific issues with subprocess handling on Windows (stderr/stdout buffering, pipe handling) by adopting the threading pattern already used successfully in examples/http/aiohttp_and_flask/test_provider.py. Additionally, it re-enables 61 compatibility suite tests that were previously disabled on Windows.
Key Changes
- Replaced subprocess-based Flask server startup with thread-based approach in
tests/test_match.py - Implemented dynamic port allocation using
pact._util.find_free_port() - Removed Windows-specific test skips across compatibility suite test files (V1-V4 provider and message tests)
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_match.py | Refactored start_provider() to use threading instead of subprocess, eliminating Windows-specific server startup issues |
| tests/compatibility_suite/test_v1_provider.py | Removed @pytest.mark.skipif decorators for Windows, re-enabling 28 provider tests |
| tests/compatibility_suite/test_v2_provider.py | Removed Windows skip decorators, re-enabling 4 V2 provider tests |
| tests/compatibility_suite/test_v3_provider.py | Removed Windows skip decorators, re-enabling 2 V3 provider tests |
| tests/compatibility_suite/test_v3_message_producer.py | Removed Windows skip decorators, re-enabling 19 V3 message provider tests |
| tests/compatibility_suite/test_v3_http_matching.py | Removed Windows skip decorators, re-enabling 8 V3 HTTP matching tests |
| tests/compatibility_suite/test_v4_provider.py | Removed Windows skip decorators, re-enabling 2 V4 provider tests |
| tests/compatibility_suite/test_v4_message_provider.py | Removed Windows skip decorators, re-enabling 2 V4 message provider tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
307d1f4 to
3d1a6c1
Compare
3d1a6c1 to
9e2d2b5
Compare
|
The CI failure is caused by a port already in use in an unrelated test. All Windows provider tests now pass with the threading fix. |
JP-Ellis
left a comment
There was a problem hiding this comment.
Awesome work! Very neat 🚀
Pre-flight checklist
Summary
This PR fixes Windows CI failures by refactoring
tests/test_match.pyto use threading instead of subprocess for starting the Flask provider server. The threading approach matches the pattern used inexamples/http/aiohttp_and_flask/test_provider.pyand avoids Windows-specific subprocess issues with stderr/stdout buffering and process handling.Additionally, this re-enables 61 previously disabled compatibility suite tests that were skipped on Windows due to this issue.
Motivation
Issue #639 identified that provider tests fail on Windows because the Flask server started via
subprocess.Popencannot be reached. The subprocess approach has known issues on Windows with:The threading approach eliminates these platform-specific issues and uses
pact._util.find_free_port()for dynamic port allocation as requested by maintainers.Test Plan
🔗 Related issues/PRs