Ticket #520 (assigned defect)
models defined in tests are not created by South
|Reported by:||joeri@…||Owned by:||andrew|
Sometimes you want to test a new model in your unit tests. With Django, models defined in tests.py are created automatically (they are created by the regular syncdb when running the test command).
from django.test import TestCase from django.db import models from myproject.myapp.models import MyAbstractBaseModel class MyTestModel(MyAbstractBaseModel): name = models.CharField(blank=False, max_length=100) class Meta: app_label = 'myapp' class SimpleTests(TestCase): def test_my_test_model(self): MyTestModel.objects.all()
These models in tests.py usually need an app_label of an existing application to be picked up. However, when the application is under South, these test models are skipped by Django and not picked up by South either.
A simple work around for now is to set the app_label to use an application that is not under South, unless the app_label is actually important for your tests.