#25251: TransactionTestCase and --keepdb
-----------------------------------+--------------------
Reporter: davidszotten | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
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: }}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25251>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/055.3bf03f00153c7c73d4a92fc09361eb3e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.