mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-18 12:12:19 +03:00
fix formatting issues for list serializer validation fix
This commit is contained in:
parent
a717d74f3c
commit
4bbc689ec5
|
@ -592,7 +592,7 @@ class ListSerializer(BaseSerializer):
|
|||
|
||||
if kwargs.get('instance', []) and kwargs.get('data', []):
|
||||
assert len(kwargs.get("data", [])) == len(
|
||||
kwargs.get("instance", [])), 'Data and instance should have same length'
|
||||
kwargs.get("instance", [])), 'Data and instance should have same length'
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
self.child.bind(field_name='', parent=self)
|
||||
|
|
|
@ -2,6 +2,7 @@ import inspect
|
|||
import pickle
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
from collections import ChainMap
|
||||
from collections.abc import Mapping
|
||||
|
||||
|
@ -10,7 +11,6 @@ from django.db import models
|
|||
|
||||
from rest_framework import exceptions, fields, relations, serializers
|
||||
from rest_framework.fields import Field
|
||||
|
||||
from .models import (
|
||||
ForeignKeyTarget, NestedForeignKeySource, NullableForeignKeySource
|
||||
)
|
||||
|
@ -787,9 +787,6 @@ class MyClassSerializer(serializers.ModelSerializer):
|
|||
return value
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
class TestMultipleObjectsValidation(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.objs = [
|
||||
|
@ -818,7 +815,7 @@ class TestMultipleObjectsValidation(unittest.TestCase):
|
|||
def test_exception_raised_when_data_and_instance_length_different(self):
|
||||
|
||||
with self.assertRaises(AssertionError):
|
||||
serializer = MyClassSerializer(
|
||||
MyClassSerializer(
|
||||
data=[{'value': 'set', 'id': instance.id} for instance in
|
||||
self.objs],
|
||||
instance=self.objs[:-1],
|
||||
|
|
Loading…
Reference in New Issue
Block a user