def testSubObjectMismatch(self): mock = simple_mock.MockObject() mock.bar = simple_mock.MockObject(mock) mock.ExpectCall('foo').WithArgs(_, 4) mock.bar.ExpectCall('baz') self.assertRaises(Exception, lambda: mock.bar.baz()) # pylint: disable=W0108
def testSubObject(self): mock = simple_mock.MockObject() mock.bar = simple_mock.MockObject(mock) mock.ExpectCall('foo').WithArgs(_, 4) mock.bar.ExpectCall('baz') mock.foo(0, 4) mock.bar.baz()
def testOnCall(self): mock = simple_mock.MockObject() handler_called = [] def Handler(arg0): assert arg0 == 7 handler_called.append(True) mock.ExpectCall('baz', 7).WhenCalled(Handler) mock.baz(7) self.assertTrue(len(handler_called) > 0)
def __init__(self): super(MockTab, self).__init__() self.runtime = simple_mock.MockObject(self) self.page = simple_mock.MockObject(self)
def testArgsDontCare(self): mock = simple_mock.MockObject() mock.ExpectCall('foo').WithArgs(_, 4) mock.foo(4, 4)
def testArgsMismatch(self): mock = simple_mock.MockObject() mock.ExpectCall('foo').WithArgs(3, 4) self.assertRaises(Exception, lambda: mock.foo(4, 4))
def testArgs2(self): mock = simple_mock.MockObject() mock.ExpectCall('foo', 3, 4) mock.foo(3, 4)
def testArgs(self): mock = simple_mock.MockObject() mock.ExpectCall('foo').WithArgs(3, 4) mock.foo(3, 4)
def testReturn(self): mock = simple_mock.MockObject() mock.ExpectCall('foo').WillReturn(7) ret = mock.foo() self.assertEquals(ret, 7)
def testBasic(self): mock = simple_mock.MockObject() mock.ExpectCall('foo') mock.foo()