Scrapy, a fast high-level web crawling & scraping framework for Python.
Simplify the changes after the merge
Andrey Rahmatullin6c0890ff54a8
diff --git a/tests/test_pipeline_images.py b/tests/test_pipeline_images.pyindex 81c9a027a..0c9a5733f 100644--- a/tests/test_pipeline_images.py+++ b/tests/test_pipeline_images.py@@ -7,7 +7,6 @@ from shutil import rmtreefrom tempfile import mkdtempfrom unittest import skipIffrom unittest.mock import patch-from warnings import catch_warningsimport attrfrom itemadapter import ItemAdapter@@ -91,6 +90,22 @@ class ImagesPipelineTestCase(unittest.TestCase):info=object()),'thumbs/50/850233df65a5b83361798f532f1fc549cd13cbe9.jpg')+ def test_thumbnail_name_from_item(self):+ """+ Custom thumbnail name based on item data, overriding default implementation+ """++ class CustomImagesPipeline(ImagesPipeline):+ def thumb_path(self, request, thumb_id, response=None, info=None, item=None):+ return f"thumb/{thumb_id}/{item.get('path')}"++ thumb_path = CustomImagesPipeline.from_settings(Settings(+ {'IMAGES_STORE': self.tempdir}+ )).thumb_path+ item = dict(path='path-to-store-file')+ request = Request("http://example.com")+ self.assertEqual(thumb_path(request, 'small', item=item), 'thumb/small/path-to-store-file')+def test_get_images_exception(self):self.pipeline.min_width = 100self.pipeline.min_height = 100@@ -231,22 +246,6 @@ class ImagesPipelineTestCase(unittest.TestCase):self.assertEqual(converted.mode, 'RGB')self.assertEqual(converted.getcolors(), [(10000, (205, 230, 255))])- def test_thumbnail_name_from_item(self):- """- Custom thumbnail name based on item data, overriding default implementation- """-- class CustomImagesPipeline(ImagesPipeline):- def thumb_path(self, request, thumb_id, response=None, info=None, item=None):- return f"thumb/{thumb_id}/{item.get('path')}"-- thumb_path = CustomImagesPipeline.from_settings(Settings(- {'IMAGES_STORE': self.tempdir}- )).thumb_path- item = dict(path='path-to-store-file')- request = Request("http://example.com")- self.assertEqual(thumb_path(request, 'small', item=item), 'thumb/small/path-to-store-file')-class DeprecatedImagesPipeline(ImagesPipeline):def file_key(self, url):@@ -536,11 +535,11 @@ class NoimagesDropTestCase(unittest.TestCase):def test_deprecation_warning(self):arg = str()- with catch_warnings(record=True) as warnings:+ with warnings.catch_warnings(record=True) as warnings:NoimagesDrop(arg)self.assertEqual(len(warnings), 1)self.assertEqual(warnings[0].category, ScrapyDeprecationWarning)- with catch_warnings(record=True) as warnings:+ with warnings.catch_warnings(record=True) as warnings:class SubclassedNoimagesDrop(NoimagesDrop):passSubclassedNoimagesDrop(arg)