Improve the "not in" assertion output

This cleans up the generic diff and tailors the output more to this
specific assertion (based on feedback from hpk).
This commit is contained in:
Floris Bruynooghe 2011-01-25 20:47:34 +00:00
parent d8d88ede65
commit 709d5e3f2c
1 changed files with 12 additions and 1 deletions

View File

@ -165,4 +165,15 @@ def _notin_text(term, text):
head = text[:index]
tail = text[index+len(term):]
correct_text = head + tail
return _diff_text(correct_text, text)
diff = _diff_text(correct_text, text)
newdiff = ['%s is contained here:' % py.io.saferepr(term, maxsize=42)]
for line in diff:
if line.startswith('Skipping'):
continue
if line.startswith('- '):
continue
if line.startswith('+ '):
newdiff.append(' ' + line[2:])
else:
newdiff.append(line)
return newdiff