コード例 #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)
コード例 #2
0
ファイル: Mocks_test.py プロジェクト: emperor1983/mysource
    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)
コード例 #3
0
    def test_not_override_members(self):

        m = Mock()
        m.do_stuff = 2
        try:
            m.expect_do_stuff(toReturn=2)
            m.do_stuff(2)
        except AttributeError:
            self.assertEqual(m.do_stuff, 2)
            pass
        else:
            self.fail('field was replaced my a method, which is wrong!')
        self.assertEqual(m.do_stuff, 2)
コード例 #4
0
ファイル: Mocks_test.py プロジェクト: emperor1983/mysource
    def test_not_override_members(self):

        m = Mock()
        m.do_stuff = 2
        try:
            m.expect_do_stuff(toReturn=2)
            m.do_stuff(2)
        except AttributeError:
            self.assertEqual(m.do_stuff, 2)
            pass
        else:
            self.fail('field was replaced my a method, which is wrong!')
        self.assertEqual(m.do_stuff, 2)
コード例 #5
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([]))
コード例 #6
0
ファイル: Mocks_test.py プロジェクト: emperor1983/mysource
    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([]))