﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25251	Inconsistent availability of data from migrations in TestCases when using --keepdb	David Szotten	Nathan Florea	"I may have misunderstood something, but {{{ keepdb }}} doesn't work as i expect when used with TransactionTestCase.

{{{
# models.py

class Model(models.Model):
    field = models.TextField()

# migrations

# 0001: default, as created by makemigrations
# 0002: datamigration

def create_data(apps, schema_editor):
    Model = apps.get_model(""app"", ""Model"")
    Model.objects.create(field='foo')


class Migration(migrations.Migration):

    dependencies = [
        ('app', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(create_data)
    ]


# tests.py

from .models import Model

class Test(TransactionTestCase):
    def test_foo(self):
        self.assertEqual(Model.objects.count(), 1)

}}}

fails with {{{ --keepdb }}} (then second time so feature is being used) 

needs a non-sqlite db so as to not use {{{ :memory: }}}"	Bug	assigned	Testing framework	1.8	Normal			romain.garrigues.cs@… rpkilby@… jedie Sarah Boyce David Sanders Sage Abdullah Sébastien Corbin Piotr Kubiak	Accepted	1	0	0	1	0	0
