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)
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))
def formfield(self, **kwargs):

View File

@ -72,7 +72,7 @@ class LocalizedFileFieldTestCase(TestCase):
@classmethod
def test_save_form_data(cls):
"""Tests whether the :see:save_form_data function correctly set
"""Tests whether the :see:save_form_data function correctly set
a valid value."""
instance = cls.FileFieldModel()
@ -87,7 +87,7 @@ class LocalizedFileFieldTestCase(TestCase):
instance = cls.FileFieldModel()
instance.file = {'en': ContentFile("test", "testfilename")}
instance._meta.get_field('file').pre_save(instance, False)
assert instance.file.en._committed == True
assert instance.file.en._committed is True
@classmethod
def test_file_methods(cls):
@ -135,17 +135,17 @@ class LocalizedFileFieldTestCase(TestCase):
@staticmethod
def test_get_prep_value():
"""Tests whether the :see:get_prep_value function returns correctly
"""Tests whether the :see:get_prep_value function returns correctly
value."""
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 LocalizedFileField().get_prep_value(value)['en'] == ''
@staticmethod
def test_formfield():
"""Tests whether the :see:formfield function correctly returns
"""Tests whether the :see:formfield function correctly returns
a valid form."""
form_field = LocalizedFileField().formfield()
@ -161,6 +161,5 @@ class LocalizedFileFieldTestCase(TestCase):
name, path, args, kwargs = LocalizedFileField().deconstruct()
assert 'upload_to' in kwargs
assert 'storage' not in kwargs
name, path, \
args, kwargs = LocalizedFileField(storage='test').deconstruct()
name, path, args, kwargs = LocalizedFileField(storage='test').deconstruct()
assert 'storage' in kwargs

View File

@ -28,7 +28,7 @@ class LocalizedFileFieldFormTestCase(TestCase):
formfield.clean(['', ''], ['', ''])
def test_bound_data(self):
"""Tests whether the :see:bound_data function is returns correctly
"""Tests whether the :see:bound_data function is returns correctly
value"""
formfield = LocalizedFileFieldForm()
@ -38,4 +38,3 @@ class LocalizedFileFieldFormTestCase(TestCase):
value = [None] * len(settings.LANGUAGES)
expected_value = [''] * len(settings.LANGUAGES)
assert formfield.bound_data(value, initial) == expected_value

View File

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

View File

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