MCPcopy
hub / github.com/scrapy/scrapy / test_result_failure

Method test_result_failure

tests/test_pipeline_media.py:499–522  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

497
498 @coroutine_test
499 async def test_result_failure(self):
500 self.pipe.LOG_FAILED_RESULTS = False
501 exc = Exception("foo")
502 req = Request(
503 "http://url1",
504 meta={"response": exc},
505 errback=self._errback,
506 )
507 item = {"requests": req}
508 with pytest.warns(
509 ScrapyDeprecationWarning, match="media_failed returned a Failure instance"
510 ):
511 new_item = await self.pipe.process_item(item)
512 assert len(new_item["results"]) == 1
513 assert new_item["results"][0][0] is False
514 assert isinstance(new_item["results"][0][1], Failure)
515 assert new_item["results"][0][1].value == exc
516 assert self.pipe._mockcalled == [
517 "get_media_requests",
518 "media_to_download",
519 "media_failed",
520 "request_errback",
521 "item_completed",
522 ]

Callers

nothing calls this directly

Calls 2

RequestClass · 0.90
process_itemMethod · 0.45

Tested by

no test coverage detected