Closed
Description
Originally reported by lc3t35 (Bitbucket: lc3t35, GitHub: lc3t35)
Here is the code
#!python
try:
_id = foo.save(something)
if _id is not None:
return Result(RESULT_OK)
except OperationFailure:
# this return statement is not stated as covered despite executed and asserted by tests
return Result(RESULT_ERROR, MESSAGE)
Here is the test :
#!python
from mock import patch
import nose.tools
def test_save_fails_if_operation_failure(self):
handler = Whatever()
with patch.object(handler, "_save") as _save_mock:
with nose.tools.assert_raises(OperationFailure):
_save_mock.side_effect = OperationFailure("message")
result = handler._save({'key': 'value'})
self.assertEqual(result.code, 'ERROR')
self.assertEqual(result.message, MESSAGE)
Test is OK of course