Skip to content

Instantly share code, notes, and snippets.

@smcoll
smcoll / test.py
Created Jul 19, 2017
Django test runner which installs HSTORE extension
View test.py
class TestRunner(runner.DiscoverRunner):
""" When migrations are disabled for the test runner, the `pre_migrate` signal
does not emit. So we need another hook for installing the extension. Prior to
Django 1.9, the `pre_syncdb` signal worked for that.
"""
def setup_databases(self, **kwargs):
"""
Always create PostgreSQL HSTORE extension if it doesn't already exist
on the database before syncing the database. Requires PostgreSQL >= 9.1