remove unnecessary code formatting changes

This commit is contained in:
Vignesh 2017-09-23 02:20:07 +08:00
parent f9125c6bb7
commit 633480957a

View File

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