MCPcopy
hub / github.com/django/django / test_add_field_binary

Method test_add_field_binary

tests/schema/tests.py:890–905  ·  view source on GitHub ↗

Tests binary fields get a sane default (#22851)

(self)

Source from the content-addressed store, hash-verified

888 self.assertTrue(columns["note_id"][1][6])
889
890 def test_add_field_binary(self):
891 """
892 Tests binary fields get a sane default (#22851)
893 """
894 # Create the table
895 with connection.schema_editor() as editor:
896 editor.create_model(Author)
897 # Add the new field
898 new_field = BinaryField(blank=True)
899 new_field.set_attributes_from_name("bits")
900 with connection.schema_editor() as editor:
901 editor.add_field(Author, new_field)
902 columns = self.column_classes(Author)
903 # MySQL annoyingly uses the same backend, so it'll come back as one of
904 # these two types.
905 self.assertIn(columns["bits"][0], ("BinaryField", "TextField"))
906
907 def test_add_field_durationfield_with_default(self):
908 with connection.schema_editor() as editor:

Callers

nothing calls this directly

Calls 6

column_classesMethod · 0.95
BinaryFieldClass · 0.90
schema_editorMethod · 0.80
create_modelMethod · 0.45
add_fieldMethod · 0.45

Tested by

no test coverage detected