diff options
author | bwarsaw <> | 2003-03-31 23:11:59 +0000 |
---|---|---|
committer | bwarsaw <> | 2003-03-31 23:11:59 +0000 |
commit | bd32ce1c3520a1b66dc48b6759184e93f7d34ba1 (patch) | |
tree | 2f16991076604c90d2d0de887d7202e733e6859d /tests | |
parent | 40550886d9ff1eb62dc2cade34e2682083dc5d98 (diff) | |
download | mailman2-bd32ce1c3520a1b66dc48b6759184e93f7d34ba1.tar.gz mailman2-bd32ce1c3520a1b66dc48b6759184e93f7d34ba1.tar.xz mailman2-bd32ce1c3520a1b66dc48b6759184e93f7d34ba1.zip |
Add ndiff hack for better error reporting of long text.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/TestBase.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/TestBase.py b/tests/TestBase.py index 816abaa2..841a9e39 100644 --- a/tests/TestBase.py +++ b/tests/TestBase.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001,2002 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2003 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -19,15 +19,34 @@ import os import shutil +import difflib import unittest +from cStringIO import StringIO from Mailman import MailList from Mailman import Utils from Mailman import mm_cfg +NL = '\n' + class TestBase(unittest.TestCase): + if hasattr(difflib, 'ndiff'): + # Python 2.2 and beyond + def ndiffAssertEqual(self, first, second): + """Like failUnlessEqual except use ndiff for readable output.""" + if first <> second: + sfirst = str(first) + ssecond = str(second) + diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines()) + fp = StringIO() + print >> fp, NL, NL.join(diff) + raise self.failureException, fp.getvalue() + else: + # Python 2.1 + ndiffAssertEqual = unittest.TestCase.assertEqual + def setUp(self): mlist = MailList.MailList() mlist.Create('_xtest', 'test@dom.ain', 'xxxxx') |