Provide forward compatibility with Python 2.5+

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30351 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3609da38
...@@ -83,12 +83,20 @@ def expectedFailure(func): ...@@ -83,12 +83,20 @@ def expectedFailure(func):
return wrapper return wrapper
class TestCase(unittest.TestCase): class TestCase(unittest.TestCase):
"""We only redefine here the run() method, and add a skipTest() """We redefine here the run() method, and add a skipTest() method.
method.
We also provide forward-compatible ._testMethodName and ._testMethodDoc
properties smooth over differences between Python 2.4 and 2.5+.
""" """
failureException = AssertionError failureException = AssertionError
if sys.version_info < (2, 5):
# BACK: in Python 2.5, __testMethodName becomes _testMethodName.
# Same for __testMethodDoc
_testMethodName = property(lambda self: self.__testMethodName)
_testMethodDoc = property(lambda self: self.__testMethodDoc)
def run(self, result=None): def run(self, result=None):
import pdb import pdb
#pdb.set_trace() #pdb.set_trace()
...@@ -112,8 +120,7 @@ class TestCase(unittest.TestCase): ...@@ -112,8 +120,7 @@ class TestCase(unittest.TestCase):
finally: finally:
result.stopTest(self) result.stopTest(self)
return return
# BACK: __testMethodName became _testMethodName in 2.7 testMethod = getattr(self, self._testMethodName)
testMethod = getattr(self, self.__testMethodName)
try: try:
success = False success = False
try: try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment