From 1d0054badb255882c3a54db2115133e674befb03 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Fri, 19 Jun 2015 16:58:58 -0400 Subject: [PATCH] Fix broken test and remove Bad test testStubOutClass_OldStyle has been fixed with a tip from referenced bug. Also testUnboundMethodsRequiresInstance was writted before python 3.3 was released and hence worked only with versions before i believe. This test never worked with python 2.6/2.7 either. So just nuking it. Closes-Bug: #1403214 Change-Id: I2b14b9b29122539cf4a101af0dca89c10693b6a3 --- mox3/mox.py | 4 +++- mox3/tests/test_mox.py | 18 ------------------ 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/mox3/mox.py b/mox3/mox.py index 3c10cc8..85d4e0c 100644 --- a/mox3/mox.py +++ b/mox3/mox.py @@ -910,7 +910,9 @@ class MethodSignatureChecker(object): except TypeError: raise ValueError('Could not get argument specification for %r' % (method,)) - if inspect.ismethod(method) or class_to_bind: + if (inspect.ismethod(method) or class_to_bind or ( + hasattr(self, '_args') and len(self._args) > 0 + and self._args[0] == 'self')): self._args = self._args[1:] # Skip 'self'. self._method = method self._instance = None # May contain the instance this is bound to. diff --git a/mox3/tests/test_mox.py b/mox3/tests/test_mox.py index 48d1ecf..ec80ed9 100644 --- a/mox3/tests/test_mox.py +++ b/mox3/tests/test_mox.py @@ -19,12 +19,10 @@ import io import re -import sys from mox3 import mox from mox3.tests import mox_helper -import six import testtools @@ -772,21 +770,6 @@ class MockAnythingTest(testtools.TestCase): class MethodCheckerTest(testtools.TestCase): """Tests MockMethod's use of MethodChecker method.""" - def testUnboundMethodsRequiresInstance(self): - # SKIP TEST IN PYTHON 2.x (Ugly hack for python 2.6) - # REASON: semantics for unbound methods has changed only in Python 3 - # so this test in earlier versions is invald - if sys.version_info < (3, 0): - return - - instance = CheckCallTestClass() - method = mox.MockMethod('NoParameters', [], False, - CheckCallTestClass.NoParameters) - - self.assertRaises(AttributeError, method) - method(instance) - self.assertRaises(AttributeError, method, instance, 1) - def testNoParameters(self): method = mox.MockMethod('NoParameters', [], False, CheckCallTestClass.NoParameters, @@ -1908,7 +1891,6 @@ class MoxTest(testtools.TestCase): # FIXME(dhellmann): Skip this test until someone can debug why it # fails on python 3.4. - @testtools.skipIf(six.PY3, "This test needs to be fixed for python 3") def testStubOutClass_OldStyle(self): """Test a mocked class whose __init__ returns a Mock.""" self.mox.StubOutWithMock(mox_helper, 'TestClassFromAnotherModule')