Re: [nose-users] How to set self.maxDiff in nose to get full diff output?

1,152 views
Skip to first unread message

Andres Riancho

unread,
Jan 24, 2013, 12:21:39 PM1/24/13
to nose-users
Not sure if that works at a module level, this is how I use it:

"""
import unittest

class TestMe(unittest.TestCase):
maxDiff = None
def test_something(self):
....
"""

You could try this:

"""
maxDiff = None

def test_something(...):
...
"""

2013/1/24 Loïc Séguin-Charbonneau <loics...@gmail.com>:
> I already posted this question to [Stack
> Overflow](http://stackoverflow.com/questions/14493670/how-to-set-self-maxdiff-in-nose-to-get-full-diff-output/)
> but I repost it here in case somebody on this list knows the answer.
>
>
> When using nose 1.2.1 with Python 3.3.0, I sometimes get an error message
> similar to the following one
>
> ======================================================================
> FAIL: maxdiff2.test_equal
> ----------------------------------------------------------------------
> Traceback (most recent call last): File
> "/usr/local/lib/python3.3/site-packages/nose/case.py", line 198, in runTest
> self.test(*self.arg)
> File "/Users/loic/cmrsj/Calculus_II/scrap/maxdiff2.py", line 32, in
> test_equal
> assert_equal(str1, str2)
> AssertionError: 'Lorem ipsum dolor sit amet, consectetur adipiscing
> elit. Donec a diam lectus.\n [truncated]... !=
> 'Suspendisse lectus leo, consectetur in tempor sit amet, placerat
> quis neque.\nE [truncated]...
> Diff is 1780 characters long. Set self.maxDiff to None to see it.
> ----------------------------------------------------------------------
> Ran 1 test in 0.064s FAILED (failures=1)
>
> In many situations, to figure out what the error really is, I need to see
> the full diff output. However, I have no idea of how to set that
> `self.maxDiff`. Googling for nose and `maxDiff` does not help. With the same
> version of nose on Python 2.7.1 the full diff is printed to screen.
>
> Here is a simple script that generates the error above when run with
> `nosetests-3.3`:
>
> from nose.tools import assert_equal
>
> def test_equal():
> str1 = """\ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
> Donec a diam lectus.
> Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec
> consectetur ante
> hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas
> mattis sit amet vitae
> augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
> Donec ut libero sed
> arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet,
> consectetur adipiscing elit.
> Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed,
> adipiscing id dolor.
> Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus
> enim sit amet elit
> pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna
> ultrices accumsan. Donec
> sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu
> rhoncus. Cum sociis
> natoque penatibus et magnis dis parturient montes, nascetur ridiculus
> mus. In rutrum
> accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in
> est."""
> str2 = """\ Suspendisse lectus leo, consectetur in tempor sit amet,
> placerat quis neque.
> Etiam luctus porttitor lorem, sed suscipit est rutrum non. Curabitur
> lobortis nisl a enim congue
> semper. Aenean commodo ultrices imperdiet. Vestibulum ut justo vel
> sapien venenatis
> tincidunt. Phasellus eget dolor sit amet ipsum dapibus condimentum vitae
> quis lectus.
> Aliquam ut massa in turpis dapibus convallis. Praesent elit lacus,
> vestibulum at malesuada et,
> ornare et est. Ut augue nunc, sodales ut euismod non, adipiscing vitae
> orci. Mauris ut placerat
> justo. Mauris in ultricies enim. Quisque nec est eleifend nulla ultrices
> egestas quis ut quam.
> Donec sollicitudin lectus a mauris pulvinar id aliquam urna cursus. Cras
> quis ligula sem, vel
> elementum mi. Phasellus non ullamcorper urna."""
> assert_equal(str1, str2)
>
>
> If I import `unittest`, put the test inside a `unittest.TestCase`, set
> `maxDiff = None`, use `assertEqual` instead of nose's `assert_equal` and run
> the test with unittest then the full difference it printed. However it does
> not work with nose. Is this a bug?
>
> --
> You received this message because you are subscribed to the Google Groups
> "nose-users" group.
> To post to this group, send email to nose-...@googlegroups.com.
> To unsubscribe from this group, send email to
> nose-users+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nose-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Andrés Riancho
Project Leader at w3af - http://w3af.org/
Web Application Attack and Audit Framework
Twitter: @w3af
GPG: 0x93C344F3
Reply all
Reply to author
Forward
0 new messages