darrenburns / pytest-clarity

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

Support for unittest asserts #6

Closed hugovk closed 5 years ago

hugovk commented 6 years ago

It would be great to add support for unittest's asserts.

For example:

import unittest

class TestClarity(unittest.TestCase):
    def test_clarity_assert(self):

        left = [1, 2, 3]
        right = [1, 2, 4]
        assert left == right

    def test_clarity_self_assert(self):

        left = [1, 2, 3]
        right = [1, 2, 4]
        self.assertEqual(left, right)

if __name__ == "__main__":
    unittest.main()

assert is nicely coloured:

image

unittest.assertEqual isn't:

image

darrenburns commented 6 years ago

Thanks for the suggestion!

Unfortunately unittest is the thing that produces the output (see here: https://github.com/python/cpython/blob/master/Lib/unittest/case.py#L1017), and so we have no control over the output of unittest test cases from the perspective of this plugin 😞

nedbat commented 5 years ago

Why leave a "wontfix" issue open?