When using nose 1.2.1 with Python 3.3.0, I sometimes get an error message similar to the following one
======================================================
In python 2.7.3, nose 1.3.0, doing the following is working for me:
assert_equal.im_class.maxDiff = None
assert_equal(huge_thing, other_huge_thing)
Here you have it (what google told me):
# http://pdf2djvu.googlecode.com/hg/tests/common.py
try:
from nose.tools import assert_multi_line_equal
except ImportError:
assert_multi_line_equal = assert_equal
else:
assert_multi_line_equal.im_class.maxDiff = None
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.
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.
I recently ran into this problem .... I was forcing a MS type line ending ....
MSstr="""hi\r
there\r"""
expected="""hi
there"""
self.assertEqual(MSsrt, expected)
That crashed with the horrible errors other are using.
In PyCharm it said the files were identical !!
I removed the \r - no more crash and tests now pass.
Hope that saves someone the 2 hours it cost me.
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>