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')