  
  
  class TestUniquenessValidation(TestCase):
      def setUp(self):
          self.instance = UniquenessModel.objects.create(username='existing')
  
      def test_repr(self):
 
</s> remove         if queryset.exists():
 </s> add         if qs_exists(queryset): </s> remove         if queryset.exists():
 </s> add         if qs_exists(queryset): </s> remove         if None not in checked_values and queryset.exists():
 </s> add         if None not in checked_values and qs_exists(queryset): </s> remove         return queryset.filter(**filter_kwargs)
 </s> add         return qs_filter(queryset, **filter_kwargs)
class IntegerFieldModel(models.Model):
    integer = models.IntegerField()


class UniquenessIntegerSerializer(serializers.Serializer):
    # Note that this field *deliberately* does not correspond with the model field.
    # This allows us to ensure that `ValueError`, `TypeError` or `DataError` etc
    # raised by a uniqueness check does not trigger a deceptive "this field is not unique"
    # validation failure.
    integer = serializers.CharField(validators=[UniqueValidator(queryset=IntegerFieldModel.objects.all())])


  
  
class IntegerFieldModel(models.Model):
    integer = models.IntegerField()


class UniquenessIntegerSerializer(serializers.Serializer):
    # Note that this field *deliberately* does not correspond with the model field.
    # This allows us to ensure that `ValueError`, `TypeError` or `DataError` etc
    # raised by a uniqueness check does not trigger a deceptive "this field is not unique"
    # validation failure.
    integer = serializers.CharField(validators=[UniqueValidator(queryset=IntegerFieldModel.objects.all())])


  class TestUniquenessValidation(TestCase):
      def setUp(self):
          self.instance = UniquenessModel.objects.create(username='existing')
  
      def test_repr(self):
keep add keep keep keep keep keep
 Robust uniqueness checks. (#4217)

* Robust uniqueness checks
* Add master to test matrix (allow_failures) 
tests/test_validators.py