I've been using Django for several years, but have recently decided to try out Flask for a new API. Thanks to Carl Meyers excellent presentation on testing Django at PyCon, I've been using the following technique to prevent touching the database in my Django unit tests:
cursor_wrapper = Mock()
cursor_wrapper.side_effect = RuntimeError("No touching the database!")
@patch('django.db.backends.util.CursorWrapper', cursor_wrapper)
class TestPurchaseModel(TestCase):
'''Purchase model test suite'''
...
My question is can anyone tell me how to do this same basic technique with SQLAlchemy? In other words, I want any time I actually run a query against the database to produce a runtime error.