Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#20681 closed Bug (fixed)

teardown_databases tries to tear down aliases, which fails

Reported by: simonpercivall Owned by: nobody
Component: Testing framework Version: 1.5
Severity: Normal Keywords:
Cc: percivall@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

If you have an aliased database, the teardown code will fail when trying to tear it down.

The patch changes setup_databases to only add a (connection, db_name) to old_names if it's not already been added by an previous alias.

Attachments (3)

0001-Don-t-try-to-tear-down-aliases-for-test-databases-it.patch (638 bytes) - added by simonpercivall 2 years ago.
0002-Don-t-try-to-tear-down-aliases-for-test-databases-it.patch (2.6 KB) - added by simonpercivall 2 years ago.
patch with test case
dont-try-to-tear-down-test-database-aliases.patch (2.6 KB) - added by anonymous 2 years ago.
patch against master

Download all attachments as: .zip

Change History (13)

comment:1 Changed 2 years ago by simonpercivall

  • Cc percivall@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 2 years ago by bmispelon

  • Has patch set
  • Needs tests set

Hi,

Could you add a test case to the patch [1]?
Test cases are required for a patch to get merged and in this case, it would also make it easier to confirm the existence of the issue.

Thanks.

[1] https://docs.djangoproject.com/en/1.5/internals/contributing/writing-code/submitting-patches/#patch-style

comment:3 Changed 2 years ago by shai

Hi,

I suspect this is either a duplicate or a regression of #14415 (the description is too terse to tell, esp. with no test case). Also, #19542 (Oracle specific) may be related.

comment:4 Changed 2 years ago by aaugustin

Not sure if that's related, but I've seen a similar problem when running tests with DATABASES = {} (in an app that doesn't have any models).

Changed 2 years ago by simonpercivall

patch with test case

comment:5 Changed 2 years ago by simonpercivall

Added new patch (more correct, I think), with test case.

The test won't work until #19940 is fixed, though.

comment:6 Changed 2 years ago by timo

  • Needs tests unset
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

Looks good Simon, could you provide a patch against master? Also please use assertEqual rather than assertEquals.

Changed 2 years ago by anonymous

patch against master

comment:7 Changed 2 years ago by simonpercivall

Patch against master uploaded. Changed from assertEquals to assertEqual, and changed the name of the test to be more descriptive.

comment:8 Changed 2 years ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In d9c580306c4b7da49d7fd2fd1ea0e6333a784113:

Fixed #20681 -- Prevented teardown_databases from attempting to tear down aliases

Thanks simonpercivall.

comment:9 Changed 2 years ago by Tim Graham <timograham@…>

In e5241902f3d4b0f925eb67809dfb732dd46ba597:

[1.6.x] Fixed #20681 -- Prevented teardown_databases from attempting to tear down aliases

Thanks simonpercivall.

Backport of d9c580306c from master

comment:10 Changed 2 years ago by Tim Graham <timograham@…>

In 8904e9fb98eaa94fd38e28706e2fe6786d3adc70:

[1.5.x] Fixed #20681 -- Prevented teardown_databases from attempting to tear down aliases

Thanks simonpercivall.

Backport of d9c580306c from master

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