Beispiel #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
Beispiel #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()
Beispiel #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)
Beispiel #4
0
    def testArgsMismatch(self):
        mock = simple_mock.MockObject()
        mock.ExpectCall('foo').WithArgs(3, 4)

        self.assertRaises(Exception, lambda: mock.foo(4, 4))
Beispiel #5
0
    def testArgsDontCare(self):
        mock = simple_mock.MockObject()
        mock.ExpectCall('foo').WithArgs(_, 4)

        mock.foo(4, 4)
Beispiel #6
0
    def testArgs2(self):
        mock = simple_mock.MockObject()
        mock.ExpectCall('foo', 3, 4)

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

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

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

        mock.foo()
 def __init__(self):
   super(MockTab, self).__init__()
   self.runtime = simple_mock.MockObject(self)
   self.page = simple_mock.MockObject(self)