simple-fastapi-container
simple-fastapi-container copied to clipboard
Fix gunicorn upgrade compatibility issue in test imports
This PR fixes the failing Dependabot PR #65 that attempted to upgrade gunicorn from 22.0.0 to 23.0.0 but failed CI due to a breaking API change.
Problem
The test file src/gunicorn_test.py was using a deprecated import pattern that was removed in gunicorn 23.x:
from gunicorn.app.wsgiapp import run
This direct function import was deprecated in favor of using the proper application class pattern.
Solution
Updated the import and test implementation to use the new API:
# Before (deprecated in gunicorn 23.x)
from gunicorn.app.wsgiapp import run
def test_config_imports():
with mock.patch.object(sys, "argv", argv):
with pytest.raises(SystemExit) as excinfo:
run()
# After (compatible with gunicorn 23.x+)
from gunicorn.app.wsgiapp import WSGIApplication
def test_config_imports():
with mock.patch.object(sys, "argv", argv):
with pytest.raises(SystemExit) as excinfo:
app = WSGIApplication()
app.run()
Changes
- Updated
gunicorn==22.0.0togunicorn==23.0.0insrc/requirements.txt - Fixed import compatibility in
src/gunicorn_test.pyto useWSGIApplicationclass - Added verification script and documentation for testing the upgrade
The new pattern maintains the same test behavior while using the supported gunicorn 23.x API. All existing functionality remains unchanged - the test still validates that gunicorn can successfully parse the application configuration.
Verification
To verify the fix works:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
python -m pytest
Fixes #79.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.