I am setting up a very simple Django project and with a very simple test like:
def test_name(self):
t = Thing.objects.create(name='a')
print(t.id)
import time
time.sleep(30)
self.assertEqual('a', t.name)
The tests passes of course, but the database (TEST
database) doesn't get populated with my Thing
model information, even though I can actually see its id
as you can see my script.
When I connect into the database, the Thing
table is always empty (I also saw some comments about it in the documentation).
Now, how can I tell Django to actually populate the data? I am using mysql, and checking the complete logs I see Django is creating a SAVEPOINT
before populating data (that is not committed) and once the test passes, it goes back into that previous SAVEPOINT
.
I am using:
Django==2.0.1
mysqlclient==1.3.12
pytest==3.3.2
pytest-django==3.1.2
I would like Django to actually populate the TEST
database, with the information from my tests and at the end drop that database, that's why I am assuming Django is creating a completely new database just for tests.