Edx platform 35175 deprecate assert dict contains subset #36236
+4
−11
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.
Description
Replace the deprecated assertDictContainsSubset method in test_course_runs.py with assertEqual. This change is necessary as assertDictContainsSubset was deprecated in Python 3.2 and removed in Python 3.11.
This change impacts the "Developer" role only, as it's a modification to the test suite.
Before:
self.assertDictContainsSubset({'team': ['Course team user does not exist']}, response.data)
After:
self.assertEqual(response.data.get('team'), ['Course team user does not exist'])
Supporting information
Related Python issue: python/cpython#28268
The change aligns with Python's deprecation of assertDictContainsSubset
Testing instructions
Navigate to the edx-platform directory
Run the specific test:
pytest cms/djangoapps/api/v1/tests/test_views/test_course_runs.py::CourseRunViewSetTests::test_create_with_invalid_course_team -v
Verify the test passes
Deadline
None - This is a maintenance update to support Python 3.11 compatibility.
Other information
This change is part of the ongoing effort to maintain Python 3.11 compatibility
![Screenshot 2025-02-10 at 10 28 02 AM](https://private-user-images.githubusercontent.com/192018463/411599072-1d0b786b-875b-4231-b310-3e47f67c52cf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5Nzg5NjgsIm5iZiI6MTczOTk3ODY2OCwicGF0aCI6Ii8xOTIwMTg0NjMvNDExNTk5MDcyLTFkMGI3ODZiLTg3NWItNDIzMS1iMzEwLTNlNDdmNjdjNTJjZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxOVQxNTI0MjhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hMWIzOWJlNzI5ZTcyMzZiMzE5MmEwYTcxYWZiMGJiNzFiNDUwYjc1ZjdjYzIxMWI2NTQzNWM3ZWY2NzdlODQ2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.s4lES21roIh60nWtHJkj5lXhpNzO2M8OY1aD0k2iG-g)
No database migrations are required
No special concerns or limitations
No dependencies on other changes