From 73e7353c00b99a47a0535a68d4c121df58ee7472 Mon Sep 17 00:00:00 2001 From: Adrian Chaves Date: Fri, 19 Jun 2026 21:00:20 +0200 Subject: [PATCH] Complete test coverage --- scrapy/_classutilities.py | 4 ++-- tests/test_scraper.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/scrapy/_classutilities.py b/scrapy/_classutilities.py index 7f82cd2cf..b788898fa 100644 --- a/scrapy/_classutilities.py +++ b/scrapy/_classutilities.py @@ -33,7 +33,7 @@ class ClassPropertyContainer: :param cls: Type of the class. :return: Value of the class property. """ - if cls is None: + if cls is None: # pragma: no cover cls = type(obj) return self.prop_get.__get__(obj, cls)() @@ -43,7 +43,7 @@ class ClassPropertyContainer: :param obj: Instance of the class. :param value: A value to be set. """ - if not self.prop_set: + if not self.prop_set: # pragma: no cover raise AttributeError("cannot set attribute") _type: type = type(obj) if _type == ClassPropertyMetaClass: diff --git a/tests/test_scraper.py b/tests/test_scraper.py index 523127ff3..194aaf0e4 100644 --- a/tests/test_scraper.py +++ b/tests/test_scraper.py @@ -62,6 +62,31 @@ class TestSlot: == "scrapy.core.scraper.Slot.MIN_RESPONSE_SIZE is deprecated." ) + def test_min_response_size_class_read(self): + with pytest.warns(ScrapyDeprecationWarning) as warning_messages: + actual = Slot.MIN_RESPONSE_SIZE + assert actual == 1024 + assert len(warning_messages) == 1 + assert ( + str(warning_messages[0].message) + == "scrapy.core.scraper.Slot.MIN_RESPONSE_SIZE is deprecated." + ) + + def test_min_response_size_class_write(self): + original = Slot._MIN_RESPONSE_SIZE + try: + with pytest.warns(ScrapyDeprecationWarning) as warning_messages: + Slot.MIN_RESPONSE_SIZE = 0 + with pytest.warns(ScrapyDeprecationWarning): + assert Slot.MIN_RESPONSE_SIZE == 0 + assert len(warning_messages) == 1 + assert ( + str(warning_messages[0].message) + == "scrapy.core.scraper.Slot.MIN_RESPONSE_SIZE is deprecated." + ) + finally: + Slot._MIN_RESPONSE_SIZE = original + def test_slot_init_max_active_size_default(self): with pytest.warns(ScrapyDeprecationWarning) as warning_messages: slot = Slot(max_active_size=5_000_000)