How to set self.maxDiff in nose to get full diff output?

This works in python 2.7:

    from unittest import TestCase
    TestCase.maxDiff = None

It'll set the default maxDiff for all TestCase instances, including the one that assert_equals and friends are attached to.


You set maxDiff to None.

But you will have to actually use a unittest.TestCase for your tests for that to work. This should work.

class MyTest(unittest.TestCase):

    maxDiff = None

    def test_diff(self):
          <your test here>

I had the same problem in Python 3 (from reading the other answers here) and using im_class did not work. The snippet below works in Python 3 (cf. How to find instance of a bound method in Python?):

assert_equal.__self__.maxDiff = None

As @Louis commented, the convenience functions are bound methods on a Dummy instance. They all seem to be on the same instance, so changing this for e.g. assert_equal will change it for assert_dict_equal et cetera. From the Python docs, __self__ is available from Python 2.6 and forward.

Tags:

Python

Nose