Exemplo n.º 1
0
    def test_callcount(self):

        m = Mock()
        m.do_stuff()
        m.do_stuff('abcd')

        m.do_more_stuff()
        m.do_more_stuff(3)
        m.do_more_stuff('with a friend')

        self.assertEqual(m.callcount_do_stuff(), 2)
        self.assertEqual(m.callcount_do_more_stuff(), 3)
Exemplo n.º 2
0
    def test_callcount(self):

        m = Mock()
        m.do_stuff()
        m.do_stuff('abcd')

        m.do_more_stuff()
        m.do_more_stuff(3)
        m.do_more_stuff('with a friend')

        self.assertEqual(m.callcount_do_stuff(), 2)
        self.assertEqual(m.callcount_do_more_stuff(), 3)
Exemplo n.º 3
0
    def test_verify(self):

        m = Mock()
        m.do_stuff()
        m.do_more_stuff()
        m.do_more_stuff(3)
        m.do_more_stuff('with a friend')

        self.assertTrue(m.verify_do_stuff())
        self.assertTrue(m.verify_do_more_stuff())
        self.assertTrue(m.verify_do_more_stuff(3))
        self.assertTrue(m.verify_do_more_stuff('with a friend'))

        self.assertFalse(m.verify_do_stuff(None))
        self.assertFalse(m.verify_do_more_stuff(0))
        self.assertFalse(m.verify_do_more_stuff(''))
        self.assertFalse(m.verify_do_more_stuff([]))
Exemplo n.º 4
0
    def test_verify(self):

        m = Mock()
        m.do_stuff()
        m.do_more_stuff()
        m.do_more_stuff(3)
        m.do_more_stuff('with a friend')

        self.assertTrue(m.verify_do_stuff())
        self.assertTrue(m.verify_do_more_stuff())
        self.assertTrue(m.verify_do_more_stuff(3))
        self.assertTrue(m.verify_do_more_stuff('with a friend'))

        self.assertFalse(m.verify_do_stuff(None))
        self.assertFalse(m.verify_do_more_stuff(0))
        self.assertFalse(m.verify_do_more_stuff(''))
        self.assertFalse(m.verify_do_more_stuff([]))