MCPcopy
hub / github.com/django/django / test_db_comments_from_abstract_model

Method test_db_comments_from_abstract_model

tests/schema/tests.py:5187–5212  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5185 @isolate_apps("schema")
5186 @skipUnlessDBFeature("supports_comments", "supports_foreign_keys")
5187 def test_db_comments_from_abstract_model(self):
5188 class AbstractModelWithDbComments(Model):
5189 name = CharField(
5190 max_length=255, db_comment="Custom comment", null=True, blank=True
5191 )
5192
5193 class Meta:
5194 app_label = "schema"
5195 abstract = True
5196 db_table_comment = "Custom table comment"
5197
5198 class ModelWithDbComments(AbstractModelWithDbComments):
5199 pass
5200
5201 with connection.schema_editor() as editor:
5202 editor.create_model(ModelWithDbComments)
5203 self.isolated_local_models = [ModelWithDbComments]
5204
5205 self.assertEqual(
5206 self.get_column_comment(ModelWithDbComments._meta.db_table, "name"),
5207 "Custom comment",
5208 )
5209 self.assertEqual(
5210 self.get_table_comment(ModelWithDbComments._meta.db_table),
5211 "Custom table comment",
5212 )
5213
5214 @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific")
5215 def test_alter_field_add_index_to_charfield(self):

Callers

nothing calls this directly

Calls 4

get_column_commentMethod · 0.95
get_table_commentMethod · 0.95
schema_editorMethod · 0.80
create_modelMethod · 0.45

Tested by

no test coverage detected