mozilla / mozilla/experimenter
Use TestCase.assertDictEqual when comparing DRF serializer errors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 151
- Forks
- 229
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 212
Description
If we call self.assertEqual(dict(), serializer.errors), TestCase.assertEqual will not dispatch to assertDictEqual because type(serializer.errors) is not dict and it falls back to the generic equality assertion function. This is what produces unusable error messages that are highly truncated.
An alternative would be to subclass django.TestCase and override _getAssertEqualityFunc to special case the dict wrapper returned by DRF.
┆Issue is synchronized with this Jira Task
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the test suite for comparisons of an empty dict with serializer.errors and inspect the surrounding TestCase usage. Replace the affected comparison with assertDictEqual, then run the relevant test module and confirm that serializer-error failures provide complete dictionary details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100