Opened 13 years ago
Closed 13 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 |
Description
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
self.connection.features.confirm()
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
else:
# 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))
connection.creation.create_test_db(
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())
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.