예제 #1
0
 def test016_verify_once_with_returns(self):
     mock = SinonMock(ForTestOnly)
     fto = ForTestOnly()
     self.assertEqual(fto.func1(), "func1")
     expectation = mock.expects("func1").once().returns(None)  #spy + stub
     self.assertEqual(fto.func1(), None)
     self.assertTrue(mock.verify())
예제 #2
0
 def test040_verify_reference_error(self):
     mock = SinonMock(ForTestOnly)
     fto = ForTestOnly()
     self.assertEqual(fto.func1(), "func1")
     expectation = mock.expects("func1").once().returns(None)  #spy + stub
     expectation.restore()
     self.assertFalse(mock.verify())
예제 #3
0
 def test012_verify_one(self):
     mock = SinonMock(ForTestOnly)
     expectation = mock.expects("func1").twice().atLeast(1).atMost(3)
     fto = ForTestOnly()
     fto.func1()
     fto.func1()
     self.assertTrue(mock.verify())  # chain conditions
예제 #4
0
 def test015_verify_once_with_throws(self):
     mock = SinonMock(ForTestOnly)
     fto = ForTestOnly()
     self.assertEqual(fto.func1(), "func1")
     expectation = mock.expects("func1").once().throws()  #spy + stub
     with self.assertRaises(Exception) as context:
         fto.func1()
     self.assertTrue(mock.verify())
예제 #5
0
 def test013_verify_multi(self):
     mock = SinonMock(ForTestOnly)
     expectation1 = mock.expects("func1").once()
     expectation2 = mock.expects("func2").atMost(1)
     fto = ForTestOnly()
     fto.func1()
     fto.func2()
     self.assertTrue(mock.verify())
예제 #6
0
 def test011_verify_one(self):
     mock = SinonMock(ForTestOnly)
     expectation = mock.expects("func1").once()
     fto = ForTestOnly()
     fto.func1()
     self.assertTrue(mock.verify())  # once condition
예제 #7
0
 def test010_verify_one(self):
     mock = SinonMock(ForTestOnly)
     expectation = mock.expects("func1")
     fto = ForTestOnly()
     self.assertTrue(mock.verify())  #no condition
예제 #8
0
 def test030_verify_false(self):
     mock = SinonMock(ForTestOnly)
     fto = ForTestOnly()
     self.assertEqual(fto.func1(), "func1")
     expectation = mock.expects("func1").once().returns(None)  #spy + stub
     self.assertFalse(mock.verify())
예제 #9
0
 def test014_verify_empty(self):
     mock = SinonMock(ForTestOnly)
     self.assertTrue(mock.verify())  #no condition