summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875>2010-08-19 13:02:12 +0000
committersmiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875>2010-08-19 13:02:12 +0000
commitabe12ce857c5978226b3d0549dceea2ab797df8a (patch)
tree08b182f1ebe265de63ac741a43cf4dcaee92d7fd
parent994820b0d3ac0b0f93249177ab90010d26d3c292 (diff)
downloadmox-abe12ce857c5978226b3d0549dceea2ab797df8a.tar.gz
git-svn-id: http://pymox.googlecode.com/svn/trunk@56 b1010a0a-674b-0410-b734-77272b80c875
-rwxr-xr-xmox.py2
-rwxr-xr-xmox_test.py23
2 files changed, 16 insertions, 9 deletions
diff --git a/mox.py b/mox.py
index a4a4fb5..d6be02a 100755
--- a/mox.py
+++ b/mox.py
@@ -898,7 +898,7 @@ class MethodSignatureChecker(object):
# correct, this will cause extra executions of the function.
if inspect.ismethod(self._method):
# The extra param accounts for the bound instance.
- if len(params) == len(self._args) + 1:
+ if len(params) == len(self._required_args) + 1:
expected = getattr(self._method, 'im_class', None)
# Check if the param is an instance of the expected class,
diff --git a/mox_test.py b/mox_test.py
index bb684de..cdc3d55 100755
--- a/mox_test.py
+++ b/mox_test.py
@@ -574,13 +574,6 @@ class MockAnythingTest(unittest.TestCase):
self.assertRaises(mox.UnexpectedMethodCallError,
self.mock_object.OtherValidCall)
-# def testReplayWithUnexpectedCell_BadSignatureWithTuple(self):
-# self.mock_object.ValidCall(mox.In((1, 2, 3)))
-# self.mock_object._Replay()
-# self.assertRaises(mox.UnexpectedMethodCallError,
-# self.mock_object.ValidCall, 4)
-
-
def testVerifyWithCompleteReplay(self):
"""Verify should not raise an exception for a valid replay."""
self.mock_object.ValidCall() # setup method call
@@ -1576,7 +1569,6 @@ class MoxTest(unittest.TestCase):
self.assertEquals('foo', actual)
def testStubOutMethod_CalledAsUnboundMethod_Subclass_Comparator(self):
- print 'this test'
self.mox.StubOutWithMock(mox_test_helper.TestClassFromAnotherModule, 'Value')
mox_test_helper.TestClassFromAnotherModule.Value(
mox.IsA(mox_test_helper.ChildClassFromAnotherModule)).AndReturn('foo')
@@ -1589,6 +1581,18 @@ class MoxTest(unittest.TestCase):
self.mox.UnsetStubs()
self.assertEquals('foo', actual)
+ def testStubOuMethod_UnboundWithOptionalParams(self):
+ self.mox = mox.Mox()
+ self.mox.StubOutWithMock(TestClass, 'OptionalArgs')
+ TestClass.OptionalArgs(mox.IgnoreArg(), foo=2)
+ self.mox.ReplayAll()
+
+ t = TestClass()
+ TestClass.OptionalArgs(t, foo=2)
+
+ self.mox.VerifyAll()
+ self.mox.UnsetStubs()
+
def testStubOutMethod_CalledAsUnboundMethod_ActualInstance(self):
instance = TestClass()
self.mox.StubOutWithMock(TestClass, 'OtherValidCall')
@@ -2044,6 +2048,9 @@ class TestClass:
def OtherValidCall(self):
pass
+ def OptionalArgs(self, foo=None):
+ pass
+
def ValidCallWithArgs(self, *args, **kwargs):
pass