class Mpa(models.Model):
....
class Meta:
abstract = True
then the project using this would have a model such as:
class MyMpa(Mpa):
....
So in the test.py files, we have to subclass 'Mpa' to create a non-
abstract model to work on.
When running a test suite _without_ south installed, the model is
recognized and the appropriate tables are created in the test db.
However, running the tests _with_ south installed, the tables are not
created and the tests fail due to the missing tables.
Can I assume this is due to some difference in south's syncdb vs the
builtin django syncdb? Any ideas on how to fix this? As a last resort
I suppose we could uninstall south when we run the tests but I'm
hoping there is a better solution.
It sounds like you have a set of migrations that doesn't rebuild the
database properly - when you run migrations from scratch on an empty
database, does it miss out any tables? Did you forget to make an
--initial migration?
(Also, what Django and South versions are you running?)
Andrew
versions: django trunk, south 0.7
We made initial migrations on all apps and migrate rebuilds the
*live*
database just fine. But our test database is significantly
different
as it requires additional models.
For example, in test.py
---------
class testMpa(Mpa):
pass
class TestStuff(TestCase):
def test_stuff(self):
testMpa.objects.whatever(...)
---------
creating these test models is required since we can't test Mpa
directly (it's an abstract base class) and we can't be certain
which
model inherits from Mpa (that depends on the project that
implements
it).
In any case, regular syncdb picks up on this and creates an
'appname_testmpa' table when running the test suite. South syncdb
doesn't appear to. Does this clarify the problem?
On 29/03/10 21:25, Andrew Godwin <andrewgod...@gmail.com> wrote:
Right, I see what you mean now - it won't work with migrations, since
you have models that only appear in migrations.
In any case, this is why there's the SOUTH_TESTS_MIGRATE setting:
http://south.aeracode.org/docs/settings.html#south-tests-migrate
Set that to False, and your tests should run with syncdb as normal.