darrenburns / pytest-clarity

A plugin to improve the output of pytest with colourful unified diffs
MIT License
439 stars 23 forks source link

Cannot show the diff if using mock #22

Open roniemartinez opened 2 years ago

roniemartinez commented 2 years ago

Diffing in unittest.mock is not supported.

Note: Sample output is manageable at the level below but common tests contain more than the sample data.

Sample test:

from unittest import mock

def test_clarity():
    mocked_object = mock.MagicMock()
    mocked_object.save({"data": "wrong data"})

    mocked_object.save.assert_called_with({"data": "expected data"})

Sample output:

image\