Ejemplo n.º 1
0
    def test_should_detect_too_many_actual_invocations(self):
        self.tester.clear()
        self.tester.clear()

        verify(self.tester, times(2)).had_called_with(call.clear())
        with raises(TooManyActualInvocations):
            verify(self.tester, times(1)).had_called_with(call.clear())
Ejemplo n.º 2
0
    def test_should_detect_when_invoked_more_than_once(self):
        self.tester.add("foo")
        self.tester.clear()
        self.tester.clear()

        verify(self.tester).had_called_with(call.add("foo"))
        with raises(TooManyActualInvocations):
            verify(self.tester).had_called_with(call.clear())
Ejemplo n.º 3
0
    def test_should_verify(self):
        self.tester.clear()
        verify(self.tester).had_called_with(call.clear())

        self.tester.add("test")
        verify(self.tester).had_called_with(call.add("test"))

        verify_no_more_interactions(self.tester)
Ejemplo n.º 4
0
    def test_should_fail_verification_on_method_argument(self):
        self.tester.clear()
        self.tester.add("foo")

        verify(self.tester).had_called_with(call.clear())

        with raises(WantedButNotInvoked):
            verify(self.tester).had_called_with(call.add("bar"))
Ejemplo n.º 5
0
    def test_should_not_count_in_stubbed_invocations(self):
        when(self.tester).has_a_call(call.add('test')).then_return(False)
        when(self.tester).has_a_call(call.add('test')).then_return(True)

        self.tester.add('test')
        self.tester.add('test')

        verify(self.tester, times(2)).had_called_with(call.add('test'))
Ejemplo n.º 6
0
    def test_should_allow_verifying_interaction_never_happened(self):
        self.tester.add('one')

        verify(self.tester, never()).had_called_with(call.add('two'))
        verify(self.tester, never()).had_called_with(call.clear())

        with raises(NeverWantedButInvoked):
            verify(self.tester, never()).had_called_with(call.add('one'))
Ejemplo n.º 7
0
 def test_should_detect_actual_invocations_count_is_more_than_zero(self):
     verify(self.tester, times(0)).had_called_with(call.clear())
     with raises(WantedButNotInvoked):
         verify(self.tester, times(15)).had_called_with(call.clear())
Ejemplo n.º 8
0
 def test_should_fail_verification(self):
     with raises(WantedButNotInvoked):
         verify(self.tester).had_called_with(call.clear())
Ejemplo n.º 9
0
 def test_should_pass_when_methods_actually_not_called(self):
     verify(self.tester, times(0)).had_called_with(call.clear())
     verify(self.tester, times(0)).had_called_with(call.add("yes, I wasn't called"))
Ejemplo n.º 10
0
 def test_should_detect_actually_called_once(self):
     self.tester.clear()
     with raises(NeverWantedButInvoked):
         verify(self.tester, times(0)).had_called_with(call.clear())