On Dec 13, 2009, at 22:25 , iain duncan wrote: > Hey folks, I'm wondering how I can make a transaction fail > deliberately for testing how my transaction handling code is working. > Is there some simple mechanism for making sure > a section in a try block with session.commit() raises an exception > without altering the code?
Mock the session/connection. There are several mocking libraries for Python - http://www.google.com/search?q=python+mock+objects Personally, I prefer Mocker, which supports patching which is handy in this case --- http://labix.org/mocker#head-83d80b643ee8544628ee7a8301a72443ac51a173 If you are unfamiliar with the technique, this looks like a decent introduction: http://agiletesting.blogspot.com/2009/07/python-mock-testing-techniques-and.html Hope this helps. :-) Regards, Alex Brasetvik -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.