Opened 21 months ago
Last modified 2 days ago
#35548 assigned Bug
An error in TestCase.setUpTestData() leaks data on databases without transactions
| Reported by: | Tim Graham | Owned by: | JaeHyuckSa |
|---|---|---|---|
| Component: | Testing framework | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
While working on a backend for MongoDB, I found that an exception on the fourth line of expressions.tests.ExpressionsNumericTests.setUpTestData left Number rows in the database such that a later test failed like this:
======================================================================
ERROR: test_F_reuse (expressions.tests.ExpressionsTests.test_F_reuse)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/tests/expressions/tests.py", line 1217, in test_F_reuse
self.assertEqual(n_qs.get(), n)
^^^^^^^^^^
File "/home/tim/code/django/django/db/models/query.py", line 652, in get
raise self.model.MultipleObjectsReturned(
expressions.models.Number.MultipleObjectsReturned: get() returned more than one Number -- it returned more than 20!
This is the same problem as #25176 but for databases with DatabaseFeatures.supports_transactions = False.
Change History (12)
comment:1 by , 21 months ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 21 months ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:3 by , 21 months ago
| Has patch: | set |
|---|
comment:4 by , 21 months ago
| Needs tests: | set |
|---|
The PR lacks any tests. Perhaps inspiration could be taken from 0abb06930fc0686cb35079934e5bb40df66f5691.
comment:5 by , 11 months ago
| Owner: | removed |
|---|---|
| Status: | assigned → new |
comment:6 by , 7 months ago
| Needs tests: | unset |
|---|---|
| Owner: | set to |
| Status: | new → assigned |
comment:8 by , 5 months ago
| Needs documentation: | unset |
|---|
comment:9 by , 3 days ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:10 by , 3 days ago
| Triage Stage: | Ready for checkin → Accepted |
|---|
As I also mentioned on the other ticket, please refrain from modifying the Triage Stage directly.
comment:11 by , 3 days ago
In their defence, there is guidance that says members can mark tickets ready for checkin
https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/#ready-for-checkin
The ticket was reviewed by any member of the community other than the person who supplied the patch and found to meet all the requirements for a commit-ready contribution. A merger now needs to give a final review prior to being committed.
https://forum.djangoproject.com/t/django-ticket-status-change/16239
It does sort of elude that if a member things a patch meets all the requirements they can mark it ready for checkin
I know it's not the usual practise though.
comment:12 by , 2 days ago
Right, I like it when people set Ready for Checkin, because it clarifies that I'm not the blocker for everything. The other mergers and I are only blockers on the stuff marked RFC. So when someone does that, it floats to the top of my list as a way of respecting the time the reviewer donated.
I think the following should do and also avoid a lack of rolling back transaction when they are supported
django/test/testcases.py
Only lightly tested though.