pytest-dev / pytest-dev/pytest-django

No obvious way to set `self.maxDiff` with `pytest_django.asserts`

Open
#1,155 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
367
PR merge metrics
No merged PRs in 30d

Description

When using pytest_django.asserts.assertXMLEqual, the diff in the console is truncated, with the following message at the end:

Diff is ### characters long. Set self.maxDiff to None to see it.

It's not obvious to me what the right way to accomplish this with pytest-django is, since the TestCase for these functions is defined internally. Right now I'm just monkeypatching unittest.case.TestCase.maxDiff, but it'd be nice to have an obvious way of doing this.

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

Start in pytest_django/asserts.py at the internally defined TestCase around lines 23–25, and trace how assertXMLEqual uses unittest's maxDiff. Review the issue discussion for the expected configuration approach. Done means users can control the diff limit through pytest-django without monkeypatching unittest.case.TestCase.maxDiff.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.