예제 #1
0
    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
예제 #2
0
    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()
예제 #3
0
    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)
예제 #4
0
 def __init__(self):
     super(MockTab, self).__init__()
     self.runtime = simple_mock.MockObject(self)
     self.page = simple_mock.MockObject(self)
예제 #5
0
    def testArgsDontCare(self):
        mock = simple_mock.MockObject()
        mock.ExpectCall('foo').WithArgs(_, 4)

        mock.foo(4, 4)
예제 #6
0
    def testArgsMismatch(self):
        mock = simple_mock.MockObject()
        mock.ExpectCall('foo').WithArgs(3, 4)

        self.assertRaises(Exception, lambda: mock.foo(4, 4))
예제 #7
0
    def testArgs2(self):
        mock = simple_mock.MockObject()
        mock.ExpectCall('foo', 3, 4)

        mock.foo(3, 4)
예제 #8
0
    def testArgs(self):
        mock = simple_mock.MockObject()
        mock.ExpectCall('foo').WithArgs(3, 4)

        mock.foo(3, 4)
예제 #9
0
    def testReturn(self):
        mock = simple_mock.MockObject()
        mock.ExpectCall('foo').WillReturn(7)

        ret = mock.foo()
        self.assertEquals(ret, 7)
예제 #10
0
    def testBasic(self):
        mock = simple_mock.MockObject()
        mock.ExpectCall('foo')

        mock.foo()