Fix outstanding PEP8 and Flake8 issues

This commit is contained in:
Swen Kooij 2017-07-15 14:06:50 +03:00
parent 5ac05efbd0
commit 08690ab361
5 changed files with 9 additions and 14 deletions

View File

@ -207,7 +207,7 @@ class LocalizedField(HStoreField):
lang_val = getattr(value, settings.LANGUAGE_CODE) lang_val = getattr(value, settings.LANGUAGE_CODE)
if lang_val is None: if lang_val is None:
raise IntegrityError('null value in column "%s.%s" violates' \ raise IntegrityError('null value in column "%s.%s" violates '
'not-null constraint' % (self.name, lang)) 'not-null constraint' % (self.name, lang))
def formfield(self, **kwargs): def formfield(self, **kwargs):

View File

@ -87,7 +87,7 @@ class LocalizedFileFieldTestCase(TestCase):
instance = cls.FileFieldModel() instance = cls.FileFieldModel()
instance.file = {'en': ContentFile("test", "testfilename")} instance.file = {'en': ContentFile("test", "testfilename")}
instance._meta.get_field('file').pre_save(instance, False) instance._meta.get_field('file').pre_save(instance, False)
assert instance.file.en._committed == True assert instance.file.en._committed is True
@classmethod @classmethod
def test_file_methods(cls): def test_file_methods(cls):
@ -139,7 +139,7 @@ class LocalizedFileFieldTestCase(TestCase):
value.""" value."""
value = LocalizedValue({'en': None}) value = LocalizedValue({'en': None})
assert LocalizedFileField().get_prep_value(None) == None assert LocalizedFileField().get_prep_value(None) is None
assert isinstance(LocalizedFileField().get_prep_value(value), dict) assert isinstance(LocalizedFileField().get_prep_value(value), dict)
assert LocalizedFileField().get_prep_value(value)['en'] == '' assert LocalizedFileField().get_prep_value(value)['en'] == ''
@ -161,6 +161,5 @@ class LocalizedFileFieldTestCase(TestCase):
name, path, args, kwargs = LocalizedFileField().deconstruct() name, path, args, kwargs = LocalizedFileField().deconstruct()
assert 'upload_to' in kwargs assert 'upload_to' in kwargs
assert 'storage' not in kwargs assert 'storage' not in kwargs
name, path, \ name, path, args, kwargs = LocalizedFileField(storage='test').deconstruct()
args, kwargs = LocalizedFileField(storage='test').deconstruct()
assert 'storage' in kwargs assert 'storage' in kwargs

View File

@ -38,4 +38,3 @@ class LocalizedFileFieldFormTestCase(TestCase):
value = [None] * len(settings.LANGUAGES) value = [None] * len(settings.LANGUAGES)
expected_value = [''] * len(settings.LANGUAGES) expected_value = [''] * len(settings.LANGUAGES)
assert formfield.bound_data(value, initial) == expected_value assert formfield.bound_data(value, initial) == expected_value

View File

@ -124,7 +124,7 @@ class LocalizedSlugFieldTestCase(TestCase):
def generate_slug(instance): def generate_slug(instance):
return instance.title return instance.title
model = get_fake_model({ get_fake_model({
'title': LocalizedField(), 'title': LocalizedField(),
'slug': LocalizedUniqueSlugField(populate_from=generate_slug) 'slug': LocalizedUniqueSlugField(populate_from=generate_slug)
}) })
@ -138,7 +138,6 @@ class LocalizedSlugFieldTestCase(TestCase):
for lang_code, lang_name in settings.LANGUAGES: for lang_code, lang_name in settings.LANGUAGES:
assert obj.slug.get(lang_code) == 'title-%s' % lang_name.lower() assert obj.slug.get(lang_code) == 'title-%s' % lang_name.lower()
@staticmethod @staticmethod
def test_populate_multiple_from_fields(): def test_populate_multiple_from_fields():
"""Tests whether populating the slug from multiple """Tests whether populating the slug from multiple

View File

@ -149,8 +149,6 @@ class LocalizedValueTestCase(TestCase):
__str__'s fallback functionality properly respects __str__'s fallback functionality properly respects
the LOCALIZED_FIELDS_FALLBACKS setting.""" the LOCALIZED_FIELDS_FALLBACKS setting."""
test_value = 'myvalue'
settings.LOCALIZED_FIELDS_FALLBACKS = { settings.LOCALIZED_FIELDS_FALLBACKS = {
'nl': ['ro'] 'nl': ['ro']
} }