Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 1796:4de2e611b6f3
Simplify Message comparison.
| author | Johannes Gijsbers <jlgijsbers@users.sourceforge.net> |
|---|---|
| date | Sun, 07 Sep 2003 18:27:47 +0000 |
| parents | 08b013acfec8 |
| children | c1eec970d5c0 |
comparison
equal
deleted
inserted
replaced
| 1795:08b013acfec8 | 1796:4de2e611b6f3 |
|---|---|
| 6 # | 6 # |
| 7 # This module is distributed in the hope that it will be useful, | 7 # This module is distributed in the hope that it will be useful, |
| 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 10 # | 10 # |
| 11 # $Id: test_mailgw.py,v 1.49 2003-09-07 13:08:08 jlgijsbers Exp $ | 11 # $Id: test_mailgw.py,v 1.50 2003-09-07 18:27:47 jlgijsbers Exp $ |
| 12 | 12 |
| 13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 | 13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 |
| 14 | 14 |
| 15 from cStringIO import StringIO | 15 from cStringIO import StringIO |
| 16 | 16 |
| 23 rfc822.Message.__init__(self, StringIO(s.strip())) | 23 rfc822.Message.__init__(self, StringIO(s.strip())) |
| 24 | 24 |
| 25 def __eq__(self, other): | 25 def __eq__(self, other): |
| 26 del self['date'], other['date'] | 26 del self['date'], other['date'] |
| 27 | 27 |
| 28 self.headers.sort() | 28 return (self.dict == other.dict and |
| 29 other.headers.sort() | |
| 30 | |
| 31 self.rewindbody() | |
| 32 other.rewindbody() | |
| 33 | |
| 34 return (self.headers == other.headers and | |
| 35 self.fp.read() == other.fp.read()) | 29 self.fp.read() == other.fp.read()) |
| 36 | 30 |
| 37 # TODO: Do a semantic diff instead of a straight text diff when a test fails. | 31 # TODO: Do a semantic diff instead of a straight text diff when a test fails. |
| 38 class DiffHelper: | 32 class DiffHelper: |
| 39 def compareMessages(self, s2, s1): | 33 def compareMessages(self, s2, s1): |
