From 9685f6327fae73fabc6061fe63088022fa4f0c78 Mon Sep 17 00:00:00 2001 From: grubert Date: Tue, 1 May 2012 08:34:41 +0000 Subject: [PATCH] python 2.3 alias unittest.TestCase.assertTrue (possibly reverted on next release) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@7400 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/DocutilsTestSupport.py | 4 ++++ test/test_io.py | 4 ++++ test/test_nodes.py | 5 +++++ test/test_settings.py | 6 ++++++ test/test_statemachine.py | 5 +++++ test/test_traversals.py | 5 +++++ test/test_viewlist.py | 4 ++++ 7 files changed, 33 insertions(+) diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py index 5cf95e6fc..bbe01a807 100644 --- a/test/DocutilsTestSupport.py +++ b/test/DocutilsTestSupport.py @@ -123,6 +123,10 @@ class StandardTestCase(unittest.TestCase): raise self.failureException, \ (msg or '%s == %s' % _format_str(first, second)) + # python 2.3 + if not hasattr(unittest.TestCase, "assertTrue"): + assertTrue = unittest.TestCase.failUnless + # aliases for assertion methods, deprecated since Python 2.7 failUnlessEqual = assertEquals = assertEqual diff --git a/test/test_io.py b/test/test_io.py index 6443abda4..fa77c749e 100755 --- a/test/test_io.py +++ b/test/test_io.py @@ -16,6 +16,10 @@ from docutils.error_reporting import locale_encoding class InputTests(unittest.TestCase): + # python 2.3 + if not hasattr(unittest.TestCase, "assertTrue"): + assertTrue = unittest.TestCase.failUnless + def test_bom(self): input = io.StringInput(source=b('\xef\xbb\xbf foo \xef\xbb\xbf bar'), encoding='utf8') diff --git a/test/test_nodes.py b/test/test_nodes.py index ad6b7161c..1fc3477c4 100755 --- a/test/test_nodes.py +++ b/test/test_nodes.py @@ -18,6 +18,11 @@ from docutils._compat import b debug = False +# python 2.3 +if not hasattr(unittest.TestCase, "assertTrue"): + # HACK? this changes TestCase, fixes the problem for tests executing afterwards. + # this tests break if run alone + unittest.TestCase.assertTrue = unittest.TestCase.failUnless class TextTests(unittest.TestCase): diff --git a/test/test_settings.py b/test/test_settings.py index 7bd7e40d3..fa5e8b34b 100755 --- a/test/test_settings.py +++ b/test/test_settings.py @@ -23,6 +23,12 @@ from docutils.parsers import rst warnings.filterwarnings(action='ignore', category=frontend.ConfigDeprecationWarning) +# python 2.3 +if not hasattr(unittest.TestCase, "assertTrue"): + # HACK? this changes TestCase, fixes the problem for tests executing afterwards. + # this tests break if run alone + unittest.TestCase.assertTrue = unittest.TestCase.failUnless + def fixpath(path): return os.path.abspath(os.path.join(*(path.split('/')))) diff --git a/test/test_statemachine.py b/test/test_statemachine.py index 2422adcda..e33f91736 100755 --- a/test/test_statemachine.py +++ b/test/test_statemachine.py @@ -13,6 +13,11 @@ import sys import re from DocutilsTestSupport import statemachine +# python 2.3 +if not hasattr(unittest.TestCase, "assertTrue"): + # HACK? this changes TestCase, fixes the problem for tests executing afterwards. + # this tests break if run alone + unittest.TestCase.assertTrue = unittest.TestCase.failUnless debug = False testtext = statemachine.string2lines("""\ diff --git a/test/test_traversals.py b/test/test_traversals.py index 72895aba6..76acd19ec 100755 --- a/test/test_traversals.py +++ b/test/test_traversals.py @@ -51,6 +51,11 @@ class AttentiveWriter(writers.Writer): self.document.walk(visitor) class StopTraversalTests(unittest.TestCase, docutils.SettingsSpec): + + # python 2.3 + if not hasattr(unittest.TestCase, "assertTrue"): + assertTrue = unittest.TestCase.failUnless + """ Test interrupting the visitor during traversal. In this test we stop it when we reach an attention node. diff --git a/test/test_viewlist.py b/test/test_viewlist.py index 416915da5..e1014f7f5 100755 --- a/test/test_viewlist.py +++ b/test/test_viewlist.py @@ -16,6 +16,10 @@ from DocutilsTestSupport import statemachine class ViewListTests(unittest.TestCase): + # python 2.3 + if not hasattr(unittest.TestCase, "assertTrue"): + assertTrue = unittest.TestCase.failUnless + a_list = list('abcdefg') b_list = list('AEIOU') c_list = list('XYZ') -- 2.11.4.GIT