Esempio n. 1
0
 def test_add_field_binary(self):
     """
     Tests binary fields get a sane default (#22851)
     """
     # Create the table
     with connection.schema_editor() as editor:
         editor.create_model(Author)
     # Add the new field
     new_field = BinaryField(blank=True)
     new_field.set_attributes_from_name("bits")
     with connection.schema_editor() as editor:
         editor.add_field(Author, new_field)
     # Ensure the field is right afterwards
     columns = self.column_classes(Author)
     # MySQL annoyingly uses the same backend, so it'll come back as one of
     # these two types.
     self.assertIn(columns["bits"][0], ("BinaryField", "TextField"))
Esempio n. 2
0
 def test_add_field_binary(self):
     """
     Tests binary fields get a sane default (#22851)
     """
     # Create the table
     with connection.schema_editor() as editor:
         editor.create_model(Author)
     # Add the new field
     new_field = BinaryField(blank=True)
     new_field.set_attributes_from_name("bits")
     with connection.schema_editor() as editor:
         editor.add_field(
             Author,
             new_field,
         )
     # Ensure the field is right afterwards
     columns = self.column_classes(Author)
     self.assertEqual(columns['bits'][0], "BinaryField")
Esempio n. 3
0
 def test_BinaryField(self):
     lazy_func = lazy(lambda: b'', bytes)
     self.assertIsInstance(BinaryField().get_prep_value(lazy_func()), bytes)
Esempio n. 4
0
 def test_BinaryField(self):
     self.assertIsInstance(BinaryField().get_prep_value(b''), bytes)