Opened 4 years ago

Closed 4 years ago

#18712 closed Bug (wontfix)

`DjangoTestSuiteRunner().setup_databases()` doesn't set confirm the feature to all connections in the case when there are several connections (aliases) to test DB.

Reported by: vstepanov Owned by: nobody
Component: Testing framework Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


DjangoTestSuiteRunner.setup_databases creates the database only for the first connection (alias) to test DB (calls connection.creation.create_test_db).

However, connection.creation.create_test_db after creating test DB sets connection settings:

        self.connection.settings_dict["NAME"] = test_database_name

        # Confirm the feature set of the test database

For other connections (alias) to test DB DjangoTestSuiteRunner.setup_databases sets only connection name and doesn't call confirm the feature set of the test DB (self.connection.features.confirm()).

            for alias in aliases[1:]:
                connection = connections[alias]
                if db_name:
                    old_names.append((connection, db_name, False))
                    connection.settings_dict['NAME'] = test_db_name
                    # If settings_dict['NAME'] isn't defined, we have a backend
                    # where the name isn't important -- e.g., SQLite, which
                    # uses :memory:. Force create the database instead of
                    # assuming it's a duplicate.
                    old_names.append((connection, db_name, True))
                        self.verbosity, autoclobber=not self.interactive)

As a result, other connections to test DB aren't configured and django.test.testcases.connections_support_transactions returns always False.

def connections_support_transactions():
    Returns True if all connections support transactions.
    return all(conn.features.supports_transactions
               for conn in connections.all())

Change History (1)

comment:1 Changed 4 years ago by Claude Paroz

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: wontfix
Status: newclosed

After commits [aa423575e] and [ad47364d], there is no need for feature confirmation with current code. And I don't think this is serious enough to justify some backport in 1.4.

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