From bd32ce1c3520a1b66dc48b6759184e93f7d34ba1 Mon Sep 17 00:00:00 2001 From: bwarsaw <> Date: Mon, 31 Mar 2003 23:11:59 +0000 Subject: Add ndiff hack for better error reporting of long text. --- tests/TestBase.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tests') 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') -- cgit v1.2.3