def runTest(self): self.mock_of_thing.baz.expect(oneval=matches(hamcrest.less_than(3))) self.mock_of_thing.baz.expect(oneval=matches(hamcrest.less_than(3))) self.mock_of_thing.baz.expect(oneval=matches(hamcrest.less_than(3))) self.mock_of_thing.baz.expect(oneval=matches(hamcrest.less_than(3))) self.mock_of_thing.baz(oneval=0) self.mock_of_thing.baz(oneval=1) self.mock_of_thing.baz(oneval=2) self.assertRaises(UnexpectedMethodCall, self.mock_of_thing.baz, oneval=3) self.assertRaises(UnexpectedMethodCall, self.mock_of_thing.baz, 4) self.mock_of_thing.baz(oneval=-1)
def runTest(self): self.mock_of_thing.baz.expect(matches(hamcrest.less_than(3))) self.mock_of_thing.baz.expect(matches(hamcrest.less_than(3))) self.mock_of_thing.baz.expect(matches(hamcrest.less_than(3))) self.mock_of_thing.baz.expect(matches(hamcrest.less_than(3))) self.mock_of_thing.baz(0) self.mock_of_thing.baz(1) self.mock_of_thing.baz(2) self.assertRaises(UnexpectedMethodCall, self.mock_of_thing.baz, 3) self.assertRaises(UnexpectedMethodCall, self.mock_of_thing.baz, 4) self.mock_of_thing.baz(-1)
def runTest(self): self.mock_of_thing.baz.expect( _args_matcher=matches(hamcrest.has_item('hi!')) ).times(3) self.mock_of_thing.baz('hi!', 1, 2, 3) self.mock_of_thing.baz(1, 2, 'hi!', 3, 4) self.assertRaises(UnexpectedMethodCall, self.mock_of_thing.baz, 1, 2, 3, 4) self.mock_of_thing.baz('hi!', 'hi!') # All expectations retired self.assertRaises(UnexpectedMethodCall, self.mock_of_thing.baz, 'hi!')