Python unit testing: make nose show failed assertions values
Question
is it possible to show the assertion values that failed? It shows the traceback and what kind of exception was throw but it would more practical to know which values failed.
Example:
assert result.file == file
AssertionError
Solution
assert result.file == file, "%s != %s" % (result.file, file,)
That's why ugly self.assert<Foo>
methods were introduced in unittest.TestCase
instead of nice and short asserts: self.assert<Foo>
methods know how to display failure messages.
By the way, I thought that nose do some black magic so in simple cases
assert a == b
should show meaningful error message.
OTHER TIPS
You should run nosetests -d this will display the values of the objects that fail the compare in assert.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow