mirror of
				https://github.com/SectorLabs/django-localized-fields.git
				synced 2025-11-03 19:58:56 +03:00 
			
		
		
		
	Fix outstanding PEP8 and Flake8 issues
This commit is contained in:
		@@ -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):
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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']
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user