From ee86950af4a873f91f77095a26cca17af693ae2e Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 29 Aug 2009 16:07:48 -0500 Subject: [PATCH] use correct attribute to find the instance of a bound method --HG-- branch : trunk --- py/test/compat.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/py/test/compat.py b/py/test/compat.py index 67551d71f..9a08cd070 100644 --- a/py/test/compat.py +++ b/py/test/compat.py @@ -2,13 +2,18 @@ import py from py.test.collect import Function +if py.std.sys.version_info > (3, 0): + _self = "__self__" +else: + _self = "im_self" + class TestCaseUnit(Function): """ compatibility Unit executor for TestCase methods honouring setUp and tearDown semantics. """ def runtest(self, _deprecated=None): boundmethod = self.obj - instance = boundmethod.im_self + instance = getattr(boundmethod, _self) instance.setUp() try: boundmethod()