Skip to content

Instantly share code, notes, and snippets.

@smcoll
smcoll / test.py
Created July 19, 2017 15:07
Django test runner which installs HSTORE extension
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