mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 13:54:47 +03:00
Add failing test of deepcopy issue in is_valid
This commit is contained in:
parent
498ce85f34
commit
5c343ae3e6
|
@ -5,6 +5,9 @@ import pickle
|
|||
|
||||
import pytest
|
||||
|
||||
from django.core.validators import RegexValidator
|
||||
from django.db import models
|
||||
|
||||
from rest_framework import serializers
|
||||
from rest_framework.compat import unicode_repr
|
||||
|
||||
|
@ -87,6 +90,25 @@ class TestValidateMethod:
|
|||
assert not serializer.is_valid()
|
||||
assert serializer.errors == {'char': ['Field error']}
|
||||
|
||||
def test_serializer_with_validator(self):
|
||||
class ExampleModel(models.Model):
|
||||
username = models.CharField(max_length=100)
|
||||
|
||||
class ExampleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ExampleModel
|
||||
fields = '__all__'
|
||||
extra_kwargs = {
|
||||
'username': {
|
||||
'validators': [
|
||||
RegexValidator('^\w+$'),
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
serializer = ExampleSerializer(data={})
|
||||
serializer.is_valid()
|
||||
|
||||
|
||||
class TestBaseSerializer:
|
||||
def setup(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user