[Python-Dev] [Python-checkins] cpython: provide a common method to check for RETR_DATA validity, first checking the
Éric Araujo
merwok at netwok.org
Tue Jan 17 18:27:31 CET 2012
Hi Giampaolo,
> changeset: 53a5a5b8859d
> user: Giampaolo Rodola' <g.rodola at gmail.com>
> date: Mon Jan 09 17:10:10 2012 +0100
> summary:
> provide a common method to check for RETR_DATA validity, first
> checking the expected len and then the actual data content; this
> way we get a failure on len mismatch rather than content mismatch
> (which is very long and unreadable)
My trick is to convert long strings to lists (with
data.split(appropriate line ending)) and pass them to assertEqual.
Then I get more readable element-based diffs when there is a test
failure.
Another trick I use is this (for example when I don’t want to make
too much diff noise, or when I don’t want to build the list of
expected results):
self.assertEqual(len(got), 3, got)
unittest will print the third argument on failure.
Regards
More information about the Python-Dev
mailing list