Skip to content

Instantly share code, notes, and snippets.

@rightfold

rightfold/.py Secret

Created January 28, 2016 09:04
Show Gist options
  • Save rightfold/dd69942ecd51bec2e191 to your computer and use it in GitHub Desktop.
Save rightfold/dd69942ecd51bec2e191 to your computer and use it in GitHub Desktop.
class BaseTestCase(unittest.TestCase):
def setUp(self):
self.tx = postgresql.db.begin()
postgresql.db = self.tx
for store in postgresql.__dict__.values():
for attempt in ['_PostgreSQLStore__db', '_db', 'db']:
if hasattr(store, attempt):
setattr(store, attempt, self.tx)
break
store._PostgreSQLStore__tl = threading.local()
def tearDown(self):
self.tx.__exit__(Exception, Exception(), None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment