Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An exception on commit can return 200 OK #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions repoze/tm/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,29 @@ def execute_request():
self.assertEqual(transaction.aborted, True)
self.assertEqual(dummycalled, [True])

def test_exception_on_commit(self):
app = DummyApplication()
tm = self._makeOne(app)
transaction = DummyTransactionModule()
# raise exception on commit
class Bang(Exception):
pass
def commit():
raise Bang()
transaction.commit = commit
tm.transaction = transaction
call_log = []
def mock_start_response(*args, **kw):
call_log.append((args, kw))
result = []
def process():
for chunk in tm({}, mock_start_response):
result.append(chunk)
self.assertRaises(Bang, process)
self.assertEqual(call_log, [(('500 Internal Server Error', [], None), {})])
self.assertNotEqual(result, ['hello'])


class TestAfterEnd(unittest.TestCase):
def _getTargetClass(self):
from repoze.tm import AfterEnd
Expand Down