Opened 5 days ago

Closed 2 days ago

Last modified 27 hours ago

#36008 closed Bug (fixed)

Document that TransactionTestCase.databases calls flush at the end of each test run

Reported by: Sviatoslav Abakumov Owned by: Chiemezuo
Component: Testing framework Version: 5.1
Severity: Normal Keywords:
Cc: Jacob Walls Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The docs on django.test.TransactionTestCase.databases mention 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 of the test run.

Change History (8)

comment:1 by Sarah Boyce, 5 days ago

Cc: Jacob Walls added
Component: DocumentationTesting framework
Summary: TransactionTestCase.databases discrepancyDocument that TransactionTestCase.databases calls flush at the end of each test run
Triage Stage: UnreviewedAccepted

I think you're right 👍 thank you

comment:2 by Chiemezuo, 5 days ago

Owner: set to Chiemezuo
Status: newassigned

comment:3 by Chiemezuo, 5 days ago

Hi!
I'd be very willing to work on this. Also, I'm a first-time contributor here and have previously never used trac, so my apologies if I don't get the contribution flow exactly as it should be. I'd be glad to take corrections as well!
I read that I could claim a ticket just by assigning it to myself here: https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/submitting-patches/#claiming-tickets

comment:4 by Chiemezuo, 3 days ago

Has patch: set

comment:5 by Jacob Walls, 3 days ago

comment:6 by Sarah Boyce, 2 days ago

Triage Stage: AcceptedReady for checkin

comment:7 by Sarah Boyce <42296566+sarahboyce@…>, 2 days ago

Resolution: fixed
Status: assignedclosed

In e9ed9ec0:

Fixed #36008 -- Fixed order of database reset in TransactionTestCase docs.

comment:8 by Sarah Boyce <42296566+sarahboyce@…>, 27 hours ago

In 274f855:

Added Chiemezuo to AUTHORS.

Refs #36008.

Note: See TracTickets for help on using tickets.
Back to Top