New submission from R. David Murray <rdmur...@bitdance.com>:

Just as with regular strings, when comparing failed output involving bytes 
strings it is really helpful to have a diff showing which bytes have changed.  
The attached patch adds an assertMultiLineEqual method to unittest and uses it 
for comparing bytes in assertEqual.

The diff output is created by first breaking the byte strings into lines using 
'splitlines(True)' just as in assertMultiLineEqual, but then each line is 
converted to a string using 'repr' before the lines sets are passed to ndiff.  
This results in output containing escaped bytes, making it easier to compare 
the differences in the byte strings.

(NB: this patch is the end result of several attempts to make the unittest 
output more useful in the email package when testing bytes handling).

----------
files: bytes_multi_line_equal.diff
keywords: patch
messages: 119280
nosy: michael.foord, r.david.murray
priority: normal
severity: normal
stage: patch review
status: open
title: Add an assertBytesMultiLineEqual to unittest and use it for bytes 
assertEqual
type: feature request
versions: Python 3.2
Added file: http://bugs.python.org/file19320/bytes_multi_line_equal.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10164>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to