Fix Python 3.10 test failures in test_get_wiki_images.py#133
Merged
Conversation
…mock.patch decorators Stacked @mock.patch decorators in mock_patch_all_web_request_methods had Python 3.10-specific behavior causing requests.get to return 404 for all core/v1/commons/file/ URLs in test_get_wiki_images.py. Replace the stacked decorator pattern with explicit context managers which work correctly across all Python versions (3.10 and 3.12).
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions job for Python (3.10)
Fix Python 3.10 test failures in test_get_wiki_images.py
Jul 14, 2026
Member
|
This is not the problem. The issue is that the API URL has changed to commons.wikimedia.org, so the PR in #132 is failing |
hyanwong
marked this pull request as ready for review
July 14, 2026 16:26
Member
|
Seems harmless, so I'll merge anyway. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
8 tests in
test_get_wiki_images.pywere failing in CI under Python 3.10 withException: Error requesting https://api.wikimedia.org/core/v1/commons/file/{name}: 404, while passing on Python 3.12. All failing tests exercised the image download path (get_image_url).Root cause
mock_patch_all_web_request_methodsused stacked@mock.patchdecorators, which in Python 3.10 caused therequests.getmock'sside_effectto not correctly interceptcore/v1/commons/file/URLs — returning 404 instead of the expected mocked response.Fix
Replace the stacked decorator pattern with explicit context managers, which apply both patches unambiguously across all Python versions:
Only
tests/test_get_wiki_images.pyis changed — no production code affected.