diff options
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') |