remove unnecessary code formatting changes

This commit is contained in:
Vignesh 2017-09-23 02:20:07 +08:00 committed by Carlton Gibson
parent 5019494042
commit 131976c06b

View File

@ -37,7 +37,7 @@ class RelatedModel(models.Model):
class RelatedModelSerializer(serializers.ModelSerializer):
username = serializers.CharField(source='user.username',
validators=[UniqueValidator(queryset=UniquenessModel.objects.all(), lookup='iexact')]) # NOQA
validators=[UniqueValidator(queryset=UniquenessModel.objects.all(), lookup='iexact')]) # NOQA
class Meta:
model = RelatedModel
@ -246,12 +246,10 @@ class TestUniquenessTogetherValidation(TestCase):
When model fields are not included in a serializer, then uniqueness
validators should not be added for that field.
"""
class ExcludedFieldSerializer(serializers.ModelSerializer):
class Meta:
model = UniquenessTogetherModel
fields = ('id', 'race_name',)
serializer = ExcludedFieldSerializer()
expected = dedent("""
ExcludedFieldSerializer():
@ -265,7 +263,6 @@ class TestUniquenessTogetherValidation(TestCase):
When serializer fields are read only, then uniqueness
validators should not be added for that field.
"""
class ReadOnlyFieldSerializer(serializers.ModelSerializer):
class Meta:
model = UniquenessTogetherModel
@ -285,7 +282,6 @@ class TestUniquenessTogetherValidation(TestCase):
"""
Ensure validators can be explicitly removed..
"""
class NoValidatorsSerializer(serializers.ModelSerializer):
class Meta:
model = UniquenessTogetherModel
@ -334,7 +330,6 @@ class TestUniquenessTogetherValidation(TestCase):
filter_queryset should add value from existing instance attribute
if it is not provided in attributes dict
"""
class MockQueryset(object):
def filter(self, **kwargs):
self.called_with = kwargs
@ -417,7 +412,6 @@ class TestUniquenessForDateValidation(TestCase):
'published': datetime.date(2000, 1, 1)
}
# Tests for `UniqueForMonthValidator`
# ----------------------------------
@ -434,6 +428,7 @@ class UniqueForMonthSerializer(serializers.ModelSerializer):
class UniqueForMonthTests(TestCase):
def setUp(self):
self.instance = UniqueForMonthModel.objects.create(
slug='existing', published='2017-01-01'
@ -456,7 +451,6 @@ class UniqueForMonthTests(TestCase):
'published': datetime.date(2017, 2, 1)
}
# Tests for `UniqueForYearValidator`
# ----------------------------------
@ -473,6 +467,7 @@ class UniqueForYearSerializer(serializers.ModelSerializer):
class UniqueForYearTests(TestCase):
def setUp(self):
self.instance = UniqueForYearModel.objects.create(
slug='existing', published='2017-01-01'
@ -538,25 +533,23 @@ class TestHiddenFieldUniquenessForDateValidation(TestCase):
class ValidatorsTests(TestCase):
def test_qs_exists_handles_type_error(self):
class TypeErrorQueryset(object):
def exists(self):
raise TypeError
assert qs_exists(TypeErrorQueryset()) is False
def test_qs_exists_handles_value_error(self):
class ValueErrorQueryset(object):
def exists(self):
raise ValueError
assert qs_exists(ValueErrorQueryset()) is False
def test_qs_exists_handles_data_error(self):
class DataErrorQueryset(object):
def exists(self):
raise DataError
assert qs_exists(DataErrorQueryset()) is False
def test_validator_raises_error_if_not_all_fields_are_provided(self):