pythondjangodjango-1.6unittest2django-hstore

Using Django DiscoverRunner with django_hstore


I have test cases created in Django 1.5 and MySQL. Our team has since moved our application to use Django 1.6 and PostgreSQL with the django_hstore extension (1.2.2 beta).

This was working great until I tried migrating our tests to use the DiscoverRunner test suite.

The problem seems to be that DjangoTestRunner would load all the applications defined in INSTALLED_APPS, but DiscoverRunner no longer loads them.

The error I'm getting is :

... lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
ProgrammingError: can't adapt type 'HStoreDict'

And this is because this line in src/django_hstore/models.py isn't getting run:

connection_handler.attach_handler(register_hstore_handler, vendor="postgresql", unique=True)

What is the best way to go about solving this/ensuring this application gets loaded during my tests? I've currently hacked around this by doing an explicit import of django_hstore.models, and this seems to make the error go away, but it seems to me there may be a better way to solve this.


Dropping in django_hstore 1.2.4 doesn't fix the problem.

With that version I get a similar error:

ProgrammingError: can't adapt type 'dict'

Unless I hack in the import from django_hstore import models as something. Is there a way to get the app to load without having a superfluous import like this?


Solution

  • Though it is late for me to reply but i am posting this because it may help someone for the further reference. This issue got resolved for me by upgrading django_hstore to 1.4