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
Patch contains OnceOrNeverInvocationMatcher implementation and tests for it