#2 OnceOrNeverInvocationMatcher

open
nobody
None
5
2009-01-05
2009-01-05
Oleg Sakharov
No

There were only three Invocation Matchers in pmock version 0.3:
- OnceInvocationMatcher (method once())
- AtLeastOnceInvocationMatcher (method at_least_once())
- NeverInvocationMatcher (method never())

I've added the fourth one:
- OnceOrNeverInvocationMatcher (method once_or_never())

The actual behaviour of the matcher is shown by the test:

class OnceOrNeverTest(unittest.TestCase):

def setUp(self):
self.mock = pmock.Mock()
self.mock.expects(pmock.once_or_never()).method("rabbit")

def test_uncalled(self):
self.mock.verify()

def test_call_once(self):
self.mock.proxy().rabbit()
self.mock.verify()

def test_call_too_many(self):
self.mock.proxy().rabbit()
try:
self.mock.proxy().rabbit()
self.fail()
except pmock.MatchError:
pass

Discussion

  • Oleg Sakharov
    Oleg Sakharov
    2009-01-05

    Patch contains OnceOrNeverInvocationMatcher implementation and tests for it

     
    Attachments