My django app works with tables that are not managed and have the following meanings in my model:
class Meta: managed = False db_table = 'mytable'
When I run a simple test that imports a person, I get the following:
(person) bob@sh ~/person/dapi $ > python manage.py test Creating test database for alias 'default'... DatabaseError: (1060, "Duplicate column name 'db_Om_no'")
Test.py is pretty simple:
import person.management.commands.dorecall from person.models import Person from django.test import TestCase import pdb class EmailSendTests(TestCase): def test_send_email(self): person = Person.objects.all()[0] Command.send_email()
I read in django docs where he says: "For tests involving models with managed = False, you need to make sure the tables are created correctly as part of the test setup." Therefore, I understand that my problem is that I did not create the corresponding tables. Can I create a copy of the tables in test_person db created by the test environment?
Each time I run tests, test_person db is destroyed (I think) and reinstalled, so how do I create a copy of the tables in test_person . I think about this right?
Update:
I saw this question on SO and added ManagedModelTestRunner() to utils.py . Although ManagedModelTestRunner() triggered (confirmed when pbd.set_trace() inserted), I still get a Duplicate column name error. I am not getting errors when I do python manage.py syncdb (although this may not mean much, since the tables are already created - it will try to delete the table and restart syncdb to find out if I can get any hints).
source share