django not running tests after adding south

543 views Asked by At

I've come accross an issue I believe is a problem with Django South, SQLite and testing. My tests used to work before South was introduced into the application. I used to use the in-memory SQLite and everything worked fine. Now with South I get an error saying one of my DB tables already exists and it fails.

Here is the error:

> python manage.py test protocols --settings=bionetbook.settings.test
Creating test database for alias 'default'...
/Projects/project/app/venv/lib/python2.7/site-packages/django/db/models/fields/__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2013-08-09 00:00:00) while time zone support is active.
  RuntimeWarning)
FATAL ERROR - The following SQL query failed: CREATE TABLE "stuff_stuff" ("id" integer NOT NULL PRIMARY KEY, "created" datetime NOT NULL, "modified" datetime NOT NULL, "user_id" integer NOT NULL, "start" datetime NOT NULL, "name" varchar(255) NOT NULL, "data" text NULL, "slug" varchar(255) NULL);
The error was: table "stuff_stuff" already exists
 ! Error found during real run of migration! Aborting.

 ! Since you have a database that does not support running
 ! schema-altering statements in transactions, we have had 
 ! to leave it in an interim state between migrations.

! You *might* be able to recover with:   = DROP TABLE "stuff_stuff"; []

 ! The South developers regret this has happened, and would
 ! like to gently persuade you to consider a slightly
 ! easier-to-deal-with DBMS (one that supports DDL transactions)
 ! NOTE: The error which caused the migration to fail is further up.
Error in migration: stuff:0003_initial

Am I spinning my wheels trying to make these three work together? Does South not like the Test Tools and SQLite?

1

There are 1 answers

0
alecxe On BEST ANSWER

Let syncdb create your test database by specifying SOUTH_TESTS_MIGRATE = False in settings.py. Quote from docs:

If this is False, South’s test runner integration will make the test database be created using syncdb, rather than via migrations (the default).