ericholscher / django-test-utils

Utilities for testing Django applications
http://django-test-utils.readthedocs.org/
MIT License
343 stars 69 forks source link

KeyError: 'SUPPORTS_TRANSACTIONS' #6

Open ramusus opened 14 years ago

ramusus commented 14 years ago

When I try to execute quicktest with specific app I get error:

ram@ram-laptop:~/workspace/movister/web_site$ ./manage.py quicktest movister
E
Traceback (most recent call last):
  File "/home/ram/workspace/movister/web_site/django/test/testcases.py", line 256, in __call__
    self._pre_setup()
  File "/home/ram/workspace/movister/web_site/django/test/testcases.py", line 223, in _pre_setup
    self._fixture_setup()
  File "/home/ram/workspace/movister/web_site/django/test/testcases.py", line 461, in _fixture_setup
    if not connections_support_transactions():
  File "/home/ram/workspace/movister/web_site/django/test/testcases.py", line 450, in connections_support_transactions
    for conn in connections.all())
  File "/home/ram/workspace/movister/web_site/django/test/testcases.py", line 450, in <genexpr>
    for conn in connections.all())
KeyError: 'SUPPORTS_TRANSACTIONS'

DB - Postgres 8.4

DATABASE_ENGINE = 'postgresql_psycopg2'
ericholscher commented 14 years ago

Hmm, wonder if this is related to multidb? It works under my setup with postgres 8.3. What version of django are you running against?

ramusus commented 14 years ago

I use development version of django from trunk. I tried another time with r12228 - error still here. Also my version of postgres is 8.4

phoebebright commented 14 years ago

Same problem running django 1.2 beta and mysql

joelryan2k commented 14 years ago

It was a fairly easy patch to get this working with Django 1.2

Download here: http://iwcenter.com/files/0001-Made-this-work-against-django-1.2.patch

ericholscher commented 14 years ago

Thanks for the patch joel, I applied it to a 1.2 compat branch. I don't know a good way of supporting this on both versions, I guess just a bunch of if statements and such. I'll hopefully look more at it this weekend and get it into trunk so it'll work on 1.1 and 1.2

denivorium commented 14 years ago

joelryan2k's patch didn't work for my particular postgres installation. The cursor = connection.cursor() line in the try block was returning a cursor for my main db not the test db. And thus the create_test_db() was never getting called.

When I added connection.close() to the line before then I was getting an exception, but it was an OperationalError, not a DatabaseError. My temp solution is to make the except block catch ALL exceptions. Not great but it works.

Also I'm running Django 1.2.1 release and Postgres 8.4

arowla commented 13 years ago

I just created a brand new Django 1.2.3 project with a sqlite3 database, ran its one default test, and got the same error.