How to preserve the database entries between tests in Django testing?
python3 manage.py test tests --keepdb
--keepdb
preserves the database but not the table.
The tables get flushed between the tests.
Here is pseudo-code
from django.test import TestCase
class test_1(TestCase):
def function_1(self):
# Creates an entry in the database with file_path
someModel.objects.create(file_path=file_path)
class test_2(TestCase):
def function_2(self):
# needs the file_path to execute this function
someModel.objects.get(file_path=file_path)
function_2
returns an error where file_path is not found since someModel table in the database has been flushed between the tests
How can I preserve the database table between the tests so they can find the file path?
This (talks about preserving the actual database and not the table) and this (creating a chain setUp does not work if I have 100´s tests that are chained) do not cover it.