mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed E128 flake8 warnings in tests/.
This commit is contained in:
@@ -21,8 +21,7 @@ def natural_key_serializer_test(format, self):
|
||||
FKDataNaturalKey.objects.create(id=1102, data_id=None),
|
||||
]
|
||||
# Serialize the test database
|
||||
serialized_data = serializers.serialize(format, objects, indent=2,
|
||||
use_natural_foreign_keys=True)
|
||||
serialized_data = serializers.serialize(format, objects, indent=2, use_natural_foreign_keys=True)
|
||||
|
||||
for obj in serializers.deserialize(format, serialized_data):
|
||||
obj.save()
|
||||
@@ -31,15 +30,19 @@ def natural_key_serializer_test(format, self):
|
||||
# as the original source
|
||||
for obj in objects:
|
||||
instance = obj.__class__.objects.get(id=obj.pk)
|
||||
self.assertEqual(obj.data, instance.data,
|
||||
"Objects with PK=%d not equal; expected '%s' (%s), got '%s' (%s)" % (
|
||||
obj.pk, obj.data, type(obj.data), instance, type(instance.data))
|
||||
self.assertEqual(
|
||||
obj.data, instance.data,
|
||||
"Objects with PK=%d not equal; expected '%s' (%s), got '%s' (%s)" % (
|
||||
obj.pk, obj.data, type(obj.data), instance, type(instance.data),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def natural_key_test(format, self):
|
||||
book1 = {'data': '978-1590597255', 'title': 'The Definitive Guide to '
|
||||
'Django: Web Development Done Right'}
|
||||
book1 = {
|
||||
'data': '978-1590597255',
|
||||
'title': 'The Definitive Guide to Django: Web Development Done Right',
|
||||
}
|
||||
book2 = {'data': '978-1590599969', 'title': 'Practical Django Projects'}
|
||||
|
||||
# Create the books.
|
||||
@@ -47,9 +50,10 @@ def natural_key_test(format, self):
|
||||
james = NaturalKeyAnchor.objects.create(**book2)
|
||||
|
||||
# Serialize the books.
|
||||
string_data = serializers.serialize(format, NaturalKeyAnchor.objects.all(),
|
||||
indent=2, use_natural_foreign_keys=True,
|
||||
use_natural_primary_keys=True)
|
||||
string_data = serializers.serialize(
|
||||
format, NaturalKeyAnchor.objects.all(), indent=2,
|
||||
use_natural_foreign_keys=True, use_natural_primary_keys=True,
|
||||
)
|
||||
|
||||
# Delete one book (to prove that the natural key generation will only
|
||||
# restore the primary keys of books found in the database via the
|
||||
|
||||
Reference in New Issue
Block a user