示例#1
0
 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
示例#2
0
    def test_context_should_reraise_exceptions(self):

        raised = False
        try:
            with commit_on_success(mock.Mock()):
                raise Exception()
        except:
            raised = True
        assert raised
示例#3
0
 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