I'm writing per the following, in which I try to produce a decent error message when comparing two multiline blocks of Unicode text. The interior method that does the comparison raises an assertion, but the default explanation is useless to me
I need to add something to code such as this below:
def assert_long_strings_equal(one, other):
lines_one = one.splitlines()
lines_other = other.splitlines()
for line1, line2 in zip(lines_one, lines_other):
try:
my_assert_equal(line1, line2)
except AssertionError, error:
# Add some information to the printed result of error??!
raise
I cannot figure out how to change the printed error message in the assertionerror I catch. I always get AssertionError: u'something' != 'something else'
, which only shows the first line of the output.
How can I change the assertion message to print out whatever I want?
If it's relevant, I am using nose
to run the test.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…