I am trying to install the hstore extension before running django tests. For that, I have overridden the default DiscoverRunner's setup_databases method.
However, the extension is not installed & the tests show this error
django.db.utils.ProgrammingError: type "hstore" does not exist
Here's my code to override the default discover runner.
settings.py
TEST_RUNNER = 'project.tests.CustomDiscovererRunner'
tests.py
from django.db import DEFAULT_DB_ALIAS, connections
from django.test.runner import DiscoverRunner
class CustomDiscovererRunner(DiscoverRunner):
def setup_databases(self, **kwargs):
result = super().setup_databases(**kwargs)
connection = connections[DEFAULT_DB_ALIAS]
cursor = connection.cursor()
cursor.execute('CREATE EXTENSION IF NOT EXISTS HSTORE')
return result