Code Duplication    Length = 16-21 lines in 2 locations

tests/models.py 2 locations

@@ 145-165 (lines=21) @@
142
    )
143
144
145
def custom_render_variations(file_name, variations, storage):
146
    """Resize image to 100x100."""
147
    for _, variation in variations.items():
148
        variation_name = StdImageFieldFile.get_variation_name(
149
            file_name,
150
            variation['name']
151
        )
152
        if storage.exists(variation_name):
153
            storage.delete(variation_name)
154
155
        with storage.open(file_name) as f:
156
            with Image.open(f) as img:
157
                size = 100, 100
158
                img = img.resize(size)
159
160
                with BytesIO() as file_buffer:
161
                    img.save(file_buffer, 'JPEG')
162
                    f = ContentFile(file_buffer.getvalue())
163
                    storage.save(variation_name, f)
164
165
    return False
166
167
168
class CustomRenderVariationsModel(models.Model):
@@ 178-193 (lines=16) @@
175
    )
176
177
178
def custom_render_variations_not_returning_bool(file_name, variations,
179
                                                storage):
180
    """Save files as is BUT do not return bool."""
181
    for _, variation in variations.items():
182
        variation_name = StdImageFieldFile.get_variation_name(
183
            file_name,
184
            variation['name']
185
        )
186
        if storage.exists(variation_name):
187
            storage.delete(variation_name)
188
189
        with storage.open(file_name) as f:
190
            with Image.open(f) as img, BytesIO() as file_buffer:
191
                img.save(file_buffer, 'JPEG')
192
                f = ContentFile(file_buffer.getvalue())
193
                storage.save(variation_name, f)
194
195
196
class CustomRenderVariationsNotReturningBoolModel(models.Model):