MCPcopy
hub / github.com/django/django / test_char_field_pk_to_auto_field

Method test_char_field_pk_to_auto_field

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

Source from the content-addressed store, hash-verified

529
530 @isolate_apps("schema")
531 def test_char_field_pk_to_auto_field(self):
532 class Foo(Model):
533 id = CharField(max_length=255, primary_key=True)
534
535 class Meta:
536 app_label = "schema"
537
538 with connection.schema_editor() as editor:
539 editor.create_model(Foo)
540 self.isolated_local_models = [Foo]
541 old_field = Foo._meta.get_field("id")
542 new_field = AutoField(primary_key=True)
543 new_field.set_attributes_from_name("id")
544 new_field.model = Foo
545 with connection.schema_editor() as editor:
546 editor.alter_field(Foo, old_field, new_field, strict=True)
547
548 @skipUnlessDBFeature("supports_foreign_keys")
549 def test_fk_to_proxy(self):

Callers

nothing calls this directly

Calls 6

AutoFieldClass · 0.90
schema_editorMethod · 0.80
create_modelMethod · 0.45
get_fieldMethod · 0.45
alter_fieldMethod · 0.45

Tested by

no test coverage detected