python 3.x - Python3 How do I get assertEqual to print all the contextual info? -
i'm using unittest.testcase in python 3 , needing more info printed when assertequal finds problem.
my test function includes statement:
self.assertequal(result, exp_result, "test_svg_glyph_scale test #" + str(test_num))
upon finding error, it's supposed print result
, exp_result
, string that's in call assertequal
. however, it's truncating __repr__
outputs result
, exp_result
:
fail: test_scale (__main__.test_svg_glyph) ---------------------------------------------------------------------- traceback (most recent call last): file "svg_glyph_test.py", line 322, in test_scale self.assertequal(result, exp_result, "test_svg_glyph_scale test #" + str(test_num)) assertionerror: glyph[15 chars]5000,-0.5000) l(0.0000,1.0000) [75 chars] ]) != glyph[15 chars]5000,0.5000) l(0.0000,1.0000) [74 chars] ]) : test_svg_glyph_scale test #1
it's [15 chars] , [75 chars] see know what's being returned , expected (okay, know one) , able compare them easily.
maxdiff
seems apply string comparisons. trying compare 2 structures.
is there setting can change characters printed?
i wanted disable strange python 3-behaviour. seems way fix monkey-patch unittest.util module directly:
unittest.util._max_length = 160 # default 80, doubles
after "[25 chars]" strings gone, , read output of test failures again.
(for reference, affected code util.py on github)
Comments
Post a Comment