Refs -- Prevented connection creation in model_indexes tests.
Entering a SchemaEditor instance creates a connection but it isn't needed
for this test.
@@ -158,7 +158,7 @@ class IndexesTests(SimpleTestCase):
@skipUnlessDBFeature('supports_tablespaces')
def test_db_tablespace(self):
- with connection.schema_editor() as editor:
+ editor = connection.schema_editor()
# Index with db_tablespace attribute.
for fields in [
# Field with db_tablespace specified on model.
@@ -177,9 +177,9 @@ class IndexesTests(SimpleTestCase):
for fields in [['author'], ['shortcut', 'isbn'], ['title', 'author']]:
with self.subTest(fields=fields):
index = models.Index(fields=fields)
- # The DEFAULT_INDEX_TABLESPACE setting can't be tested
- # because it's evaluated when the model class is defined.
- # As a consequence, @override_settings doesn't work.
+ # The DEFAULT_INDEX_TABLESPACE setting can't be tested because
+ # it's evaluated when the model class is defined. As a
+ # consequence, @override_settings doesn't work.
if settings.DEFAULT_INDEX_TABLESPACE:
self.assertIn(
'"%s"' % settings.DEFAULT_INDEX_TABLESPACE,
@@ -187,7 +187,7 @@ class IndexesTests(SimpleTestCase):
)
else:
self.assertNotIn('TABLESPACE', str(index.create_sql(Book, editor)))
- # Field with db_tablespace specified on the model and an index
- # without db_tablespace.
+ # Field with db_tablespace specified on the model and an index without
+ # db_tablespace.
index = models.Index(fields=['shortcut'])
self.assertIn('"idx_tbls"', str(index.create_sql(Book, editor)).lower())
