Skip to content

Commit d367704

Browse files
ngnpopefelixxm
authored andcommitted
Added backward compatibility test for ConnectionHandler.databases property.
The ConnectionHandler.databases property is no longer used within Django, but it is maintained for backward compatibility with 3rd party packages that have used this private API in the past.
1 parent c112f83 commit d367704

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

django/db/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ def configure_settings(self, databases):
183183

184184
@property
185185
def databases(self):
186+
# Maintained for backward compatibility as some 3rd party packages have
187+
# made use of this private API in the past. It is no longer used within
188+
# Django itself.
186189
return self.settings
187190

188191
def create_connection(self, alias):

tests/db_utils/tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ def test_no_default_database(self):
4040
with self.assertRaisesMessage(ImproperlyConfigured, msg):
4141
conns["other"].ensure_connection()
4242

43+
def test_databases_property(self):
44+
# The "databases" property is maintained for backwards compatibility
45+
# with 3rd party packages. It should be an alias of the "settings"
46+
# property.
47+
conn = ConnectionHandler({})
48+
self.assertNotEqual(conn.settings, {})
49+
self.assertEqual(conn.settings, conn.databases)
50+
4351
def test_nonexistent_alias(self):
4452
msg = "The connection 'nonexistent' doesn't exist."
4553
conns = ConnectionHandler(

0 commit comments

Comments
 (0)