NO-JIRA: [c,cpp] fix monkey-patch of python 2.7 unittest features for python 2.6
Don't apply patch on versions that have the feature. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8292110a Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8292110a Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8292110a Branch: refs/heads/master Commit: 8292110aa234df2a2826905edaebcbc79961d363 Parents: 7ba1bfa Author: Alan Conway <[email protected]> Authored: Tue Oct 16 10:09:36 2018 -0400 Committer: Alan Conway <[email protected]> Committed: Tue Oct 16 11:03:10 2018 -0400 ---------------------------------------------------------------------- tests/py/test_unittest.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8292110a/tests/py/test_unittest.py ---------------------------------------------------------------------- diff --git a/tests/py/test_unittest.py b/tests/py/test_unittest.py index afc863b..ebb8efc 100644 --- a/tests/py/test_unittest.py +++ b/tests/py/test_unittest.py @@ -19,10 +19,17 @@ import unittest -def assertMultiLineEqual(self, a, b, msg=None): self.assertEqual(a,b,msg) -unittest.TestCase.assertMultiLineEqual = assertMultiLineEqual +# Monkey-patch a few unittest 2.7 features for Python 2.6. +# +# These are note the pretty versions provided by 2.7 but they do the +# same job as far as correctness is concerned. + +if not hasattr(unittest.TestCase, "assertMultiLineEqual"): + def assertMultiLineEqual(self, a, b, msg=None): self.assertEqual(a,b,msg) + unittest.TestCase.assertMultiLineEqual = assertMultiLineEqual -def assertIn(self, a, b, msg=None): self.assertTrue(a in b,msg) -unittest.TestCase.assertIn = assertIn +if not hasattr(unittest.TestCase, "assertIn"): + def assertIn(self, a, b, msg=None): self.assertTrue(a in b,msg) + unittest.TestCase.assertIn = assertIn --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
