From 55105ddc7cc61c51cb7f1b8997a3cd4afef459c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Chaves?= Date: Thu, 30 Jun 2022 16:29:18 +0200 Subject: [PATCH] Do not warn about internal usage of ResponseTypes.CLASSES --- scrapy/responsetypes.py | 5 ++++- tests/test_responsetypes.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scrapy/responsetypes.py b/scrapy/responsetypes.py index 46dc28efb..6ae6dbd9a 100644 --- a/scrapy/responsetypes.py +++ b/scrapy/responsetypes.py @@ -56,7 +56,10 @@ class ResponseTypes(metaclass=_ResponseTypesMeta): def __init__(self): self.classes = {} self.mimetypes = _MIME_TYPES - for mimetype, cls in self.CLASSES.items(): + with catch_warnings(): + simplefilter("ignore") + classes_items = self.CLASSES.items() + for mimetype, cls in classes_items: self.classes[mimetype] = load_object(cls) def __getattribute__(self, name): diff --git a/tests/test_responsetypes.py b/tests/test_responsetypes.py index 434993c0b..5f131bd07 100644 --- a/tests/test_responsetypes.py +++ b/tests/test_responsetypes.py @@ -126,6 +126,10 @@ class ResponseTypesTest(unittest.TestCase): ) messages = {str(warning.message) for warning in warnings} self.assertIn(expected_message, messages) + unxepected_message = ( + 'scrapy.responsetypes.ResponseTypes.CLASSES is deprecated' + ) + self.assertNotIn(unxepected_message, messages) def test_class_classes_deprecation(self): with catch_warnings(record=True) as warnings: