Jari Pennanen
unread,Nov 5, 2010, 4:57:43 PM11/5/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
I've been trying to split tests.py, but I've noticed that models
defined inside test module does not work. Normally one can define
models in tests.py like this:
class JSONFieldModel(models.Model):
json = JSONField()
class JSONFieldTest(TestCase):
def setUp(self):
pass
def test_json_serialization(self):
"""JSONField serialization"""
thedata = {'test': 5}
jsdb = JSONFieldModel(json=thedata)
jsdb.save()
del jsdb
jsdb = JSONFieldModel.objects.get(pk=1)
self.failUnlessEqual(thedata, jsdb.json,
'JSON Serialization mismatch')
And they are created to test database just fine. But when I split the
tests.py to package and have tests/__init__.py import all, it throws
me error of not having database tables. Tests do start just fine, but
these models are not apparently created.
Is there any good workaround for this? I really like the idea of
splitting long tests.py to logical modules.