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
This commit is contained in:
Davanum Srinivas 2015-06-19 16:58:58 -04:00 committed by Sirushti Murugesan
parent d87a86be69
commit 1d0054badb
2 changed files with 3 additions and 19 deletions

View File

@ -910,7 +910,9 @@ class MethodSignatureChecker(object):
except TypeError: except TypeError:
raise ValueError('Could not get argument specification for %r' raise ValueError('Could not get argument specification for %r'
% (method,)) % (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._args = self._args[1:] # Skip 'self'.
self._method = method self._method = method
self._instance = None # May contain the instance this is bound to. self._instance = None # May contain the instance this is bound to.

View File

@ -19,12 +19,10 @@
import io import io
import re import re
import sys
from mox3 import mox from mox3 import mox
from mox3.tests import mox_helper from mox3.tests import mox_helper
import six
import testtools import testtools
@ -772,21 +770,6 @@ class MockAnythingTest(testtools.TestCase):
class MethodCheckerTest(testtools.TestCase): class MethodCheckerTest(testtools.TestCase):
"""Tests MockMethod's use of MethodChecker method.""" """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): def testNoParameters(self):
method = mox.MockMethod('NoParameters', [], False, method = mox.MockMethod('NoParameters', [], False,
CheckCallTestClass.NoParameters, CheckCallTestClass.NoParameters,
@ -1908,7 +1891,6 @@ class MoxTest(testtools.TestCase):
# FIXME(dhellmann): Skip this test until someone can debug why it # FIXME(dhellmann): Skip this test until someone can debug why it
# fails on python 3.4. # fails on python 3.4.
@testtools.skipIf(six.PY3, "This test needs to be fixed for python 3")
def testStubOutClass_OldStyle(self): def testStubOutClass_OldStyle(self):
"""Test a mocked class whose __init__ returns a Mock.""" """Test a mocked class whose __init__ returns a Mock."""
self.mox.StubOutWithMock(mox_helper, 'TestClassFromAnotherModule') self.mox.StubOutWithMock(mox_helper, 'TestClassFromAnotherModule')