# TransactionTestCase.databases discrepancy

**URL:** https://forum.djangoproject.com/t/transactiontestcase-databases-discrepancy/37176
**Category:** Documentation
**Created:** [December 12, 2024, 12:49pm UTC](https://forum.djangoproject.com/t/transactiontestcase-databases-discrepancy/37176 "2024-12-12T12:49:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Perlence](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/perlence/32/25741_2.png) [@Perlence](https://forum.djangoproject.com/u/Perlence)
#### Post date: [December 12, 2024, 12:49pm UTC](https://forum.djangoproject.com/t/transactiontestcase-databases-discrepancy/37176/1 "2024-12-12T12:49:41Z")

</div>

I noticed that [the docs mention](https://docs.djangoproject.com/en/5.1/topics/testing/tools/#django.test.TransactionTestCase.databases) that Django flushes the test DB at the start of the test run (emphasis mine):

> However, a big part of the time taken to run a Django `TestCase` is consumed by the call to `flush` that ensures that you have a clean database **at the start** of each test run.

> As an optimization, Django only flushes the `default` database **at the start** of each test run.

However, after tracing the code, I believe that Django flushes the DB [at the end](https://github.com/django/django/blob/stable/5.1.x/django/test/testcases.py#L1236-L1244) of the test run. Is this correct? If so, should we change these sentences in the docs?

---

<div class="post-metadata">

### Author: ![jacobtylerwalls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jacobtylerwalls/32/30603_2.png) [@jacobtylerwalls](https://forum.djangoproject.com/u/jacobtylerwalls)
#### Post date: [December 12, 2024, 4:23pm UTC](https://forum.djangoproject.com/t/transactiontestcase-databases-discrepancy/37176/2 "2024-12-12T16:23:36Z")

</div>

Funny, I noticed this the other day also. Good spot! Could you take a minute to open a [ticket](https://code.djangoproject.com/newticket)?

---

<div class="post-metadata">

### Author: ![Perlence](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/perlence/32/25741_2.png) [@Perlence](https://forum.djangoproject.com/u/Perlence)
#### Post date: [December 13, 2024, 7:32am UTC](https://forum.djangoproject.com/t/transactiontestcase-databases-discrepancy/37176/3 "2024-12-13T07:32:01Z")

</div>

Will do, thanks so much!

EDIT: Just for future reference, I’ve created ticket [#36008](https://code.djangoproject.com/ticket/36008).
