mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Appeased flake8.
This commit is contained in:
parent
fc32e9c0d9
commit
b1432bfc22
4 changed files with 10 additions and 6 deletions
|
@ -236,14 +236,18 @@ class SchemaTests(TransactionTestCase):
|
|||
Tests adding fields to models with a default that is not directly
|
||||
valid in the database (#22581)
|
||||
"""
|
||||
|
||||
class TestTransformField(IntegerField):
|
||||
|
||||
# Weird field that saves the count of items in its value
|
||||
def get_default(self):
|
||||
return self.default
|
||||
|
||||
def get_prep_value(self, value):
|
||||
if value is None:
|
||||
return 0
|
||||
return len(value)
|
||||
|
||||
# Create the table
|
||||
with connection.schema_editor() as editor:
|
||||
editor.create_model(Author)
|
||||
|
@ -251,7 +255,7 @@ class SchemaTests(TransactionTestCase):
|
|||
Author.objects.create(name="Andrew", height=30)
|
||||
Author.objects.create(name="Andrea")
|
||||
# Add the field with a default it needs to cast (to string in this case)
|
||||
new_field = TestTransformField(default={1:2})
|
||||
new_field = TestTransformField(default={1: 2})
|
||||
new_field.set_attributes_from_name("thing")
|
||||
with connection.schema_editor() as editor:
|
||||
editor.add_field(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue