mirror of https://github.com/scrapy/scrapy.git
Complete test coverage
This commit is contained in:
parent
f0e78aa677
commit
73e7353c00
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue