Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error With South When Running Unit Tests Using Nose

I'm having some difficulty getting my django tests to run properly; I'm using nose, and I started getting an error when the migrations were being applied, that from table 1 a foreign key relation to table 2 failed with the error:

django.db.utils.DatabaseError: relation "table2_column" does not exist

Looking at the way the migrations were being applied it was clear to me that table1 was not created prior to the foreign key relation was applied, so I tried to figure out how to force the dependency, and found the following article: http://south.aeracode.org/docs/dependencies.html

I then added:

depends_on = (
    ("app2", "0001_inital"),
)

to my app1/0001_initial.py file.

Unfortunately now I'm getting the following error:

south.exceptions.DependsOnUnknownMigrationMigration 'app1:0001_initial' depends on unknown migration 'app2:0001_inital'.

Any ideas on how to solve this?

like image 443
Simon Avatar asked Mar 23 '11 06:03

Simon


2 Answers

I'm not sure if this will solve your problem, but you can add a setting to use syncdb instead of migrations when running tests. Add the following line to your settings.py

SOUTH_TESTS_MIGRATE = False
like image 133
gladysbixly Avatar answered Nov 03 '22 08:11

gladysbixly


You have a typo in the name of the migration it's depending on. It should be:

depends_on = (
    ("app2", "0001_initial"),
)

This dependency system worked for me, after having exactly the same issue you list here, and then finding the dependency system South's docs.

like image 5
magopian Avatar answered Nov 03 '22 07:11

magopian