def test_expectations_with_multiple_return_values(self): db = Fake("db").expects("get_id").returns(1).expects("set_id").next_call(for_method="get_id").returns(2) eq_(db.get_id(), 1) eq_(db.set_id(), None) eq_(db.get_id(), 2) fudge.verify()
def test_returns(self): db = Fake("db")\ .provides("get_id").returns(1)\ .provides("set_id")\ .next_call(for_method="get_id").returns(2) # print [c.return_val for c in db._declared_calls["get_id"]._calls] eq_(db.get_id(), 1) eq_(db.set_id(), None) eq_(db.get_id(), 2)
def test_too_many_calls(self): db = Fake("db")\ .remember_order()\ .expects("get_id").returns(1)\ .expects("set_id") eq_(db.get_id(), 1) eq_(db.set_id(), None) # extra : eq_(db.get_id(), 1)
def test_multiple_returns_affect_order(self): db = Fake("db")\ .remember_order()\ .expects("get_id").returns(1)\ .expects("set_id")\ .next_call(for_method="get_id").returns(2) eq_(db.get_id(), 1) eq_(db.set_id(), None) eq_(db.get_id(), 2) fudge.verify()
def test_expectations_with_multiple_return_values(self): db = Fake("db")\ .expects("get_id").returns(1)\ .expects("set_id")\ .next_call(for_method="get_id").returns(2) eq_(db.get_id(), 1) eq_(db.set_id(), None) eq_(db.get_id(), 2) fudge.verify()