Scrapy, a fast high-level web crawling & scraping framework for Python.
Add deprecation warning test for scrapy.pipelines.images.NoimagesDrop
PluT00cc16af35af8b
diff --git a/tests/test_pipeline_images.py b/tests/test_pipeline_images.pyindex c69cd0e4a..613190f9c 100644--- a/tests/test_pipeline_images.py+++ b/tests/test_pipeline_images.py@@ -4,14 +4,16 @@ import randomfrom shutil import rmtreefrom tempfile import mkdtempfrom unittest import skipIf+from warnings import catch_warningsimport attrfrom itemadapter import ItemAdapterfrom twisted.trial import unittest+from scrapy.exceptions import ScrapyDeprecationWarningfrom scrapy.http import Request, Responsefrom scrapy.item import Field, Item-from scrapy.pipelines.images import ImagesPipeline+from scrapy.pipelines.images import ImagesPipeline, NoimagesDropfrom scrapy.settings import Settingsfrom scrapy.utils.python import to_bytes@@ -413,6 +415,22 @@ class ImagesPipelineTestCaseCustomSettings(unittest.TestCase):expected_value)+class NoimagesDropTestCase(unittest.TestCase):++ def test_deprecation_warning(self):+ arg = str()+ with 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:+ class SubclassedNoimagesDrop(NoimagesDrop):+ pass+ SubclassedNoimagesDrop(arg)+ self.assertEqual(len(warnings), 1)+ self.assertEqual(warnings[0].category, ScrapyDeprecationWarning)++def _create_image(format, *a, **kw):buf = io.BytesIO()Image.new(*a, **kw).save(buf, format)