def test_do_not_commit_if_exception_raised(self): open_session = mock.Mock() try: with commit_on_success(open_session): raise Exception() except: pass assert 0 == open_session.commit.call_count
def test_context_should_reraise_exceptions(self): raised = False try: with commit_on_success(mock.Mock()): raise Exception() except: raised = True assert raised
def test_commit_after_with_block(self): open_session = mock.Mock() with commit_on_success(open_session): pass assert 1 == open_session.commit.call_count