mozilla / mozilla/experimenter

Use TestCase.assertDictEqual when comparing DRF serializer errors

Open Beginner friendly
#16,198 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Maintenance Task
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.