So far, I can see two options.
Option 1: Create unmanaged model classes, and in the tests, create and destroy the database tables manually.
Option 2 (what I chose): Declare test models in my tests
module. Follow the advice here and trigger syncdb
in the test setUp
method to create the tables. Adapted for testing, here's what it looks like:
from django.core.management import call_command
from django.db import models
from django.test import TestCase
class TestModel(models.Model):
data = models.FloatField()
class Meta:
app_label = 'myapp'
class LibraryTests(TestCase):
def setUp(self):
super(LibraryTests, self).setUp()
models.register_models('myapp', TestModel)
call_command('syncdb')