Opened 8 years ago

Closed 8 years ago

Last modified 6 years ago

#26840 closed Cleanup/optimization (fixed)

Extract database teardown from DiscoverRunner, to better support third-party test runners

Reported by: Carl Meyer Owned by: nobody
Component: Testing framework Version: 1.9
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

Currently if a third-party test runner wants access to the default database teardown code, it has to instantiate a DiscoverRunner in order to call its teardown_databases method. This logic should be extracted into a standalone utility, like setup_databases already is.

Fortunately, Andreas Pelme has already done this in https://github.com/django/django/pull/6872 -- just filing a supporting Trac ticket to properly observe the forms.

Change History (5)

comment:1 by Tim Graham, 8 years ago

Patch needs improvement: set

Left comments for improvement on the PR.

comment:2 by Tim Graham, 8 years ago

Patch needs improvement: unset

comment:3 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In e76981b4:

Fixed #26840 -- Added test.utils.setup/teardown_databases().

comment:4 by Tim Graham <timograham@…>, 7 years ago

In 9463a7a:

Refs #26840 -- Removed django.test.runner.setup_databases() per deprecation timeline.

comment:5 by Tim Graham <timograham@…>, 6 years ago

In f6d8b0c4:

Refs #26840 -- Corrected SQLite connection mocking in a setup_databases() test.

The test was expecting connections used by DiscoverRunner.setup_databases()
to be the ones defined in django.test.runner but this doesn't hold true
since this method was made a proxy of django.test.utils.setup_databases.

This broke the TransactionTestCase.serialized_rollback feature in the test
suite because calls to create_db_test() cleared the test data persisted on
connections objects.

Added an assertions to prevent this from happening again.

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