@@ -0,0 +1,1978 @@
+from twisted.internet import defer%0Afrom twisted.internet.defer import Deferred%0Afrom twisted.trial import unittest%0A%0Afrom scrapy import Spider, signals, Request%0Afrom scrapy.utils.test import get_crawler%0A%0Afrom tests.mockserver import MockServer%0A%0A%0Aclass SimplePipeline:%0A    def process_item(self, item, spider):%0A        item%5B'pipeline_passed'%5D = True%0A        return item%0A%0A%0Aclass DeferredPipeline:%0A    def cb(self, item):%0A        item%5B'pipeline_passed'%5D = True%0A        return item%0A%0A    def process_item(self, item, spider):%0A        d = Deferred()%0A        d.addCallback(self.cb)%0A        d.callback(item)%0A        return d%0A%0A%0Aclass ItemSpider(Spider):%0A    name = 'itemspider'%0A%0A    def start_requests(self):%0A        yield Request(self.mockserver.url('/status?n=200'))%0A%0A    def parse(self, response):%0A        return %7B'field': 42%7D%0A%0A%0Aclass PipelineTestCase(unittest.TestCase):%0A    def setUp(self):%0A        self.mockserver = MockServer()%0A        self.mockserver.__enter__()%0A%0A    def tearDown(self):%0A        self.mockserver.__exit__(None, None, None)%0A%0A    def _on_item_scraped(self, item):%0A        self.assertIsInstance(item, dict)%0A        self.assertTrue(item.get('pipeline_passed'))%0A        self.items.append(item)%0A%0A    def _create_crawler(self, pipeline_class):%0A        settings = %7B%0A            'ITEM_PIPELINES': %7B__name__ + '.' + pipeline_class.__name__: 1%7D,%0A        %7D%0A        crawler = get_crawler(ItemSpider, settings)%0A        crawler.signals.connect(self._on_item_scraped, signals.item_scraped)%0A        self.items = %5B%5D%0A        return crawler%0A%0A    @defer.inlineCallbacks%0A    def test_simple_pipeline(self):%0A        crawler = self._create_crawler(SimplePipeline)%0A        yield crawler.crawl(mockserver=self.mockserver)%0A        self.assertEqual(len(self.items), 1)%0A%0A    @defer.inlineCallbacks%0A    def test_deferred_pipeline(self):%0A        crawler = self._create_crawler(DeferredPipeline)%0A        yield crawler.crawl(mockserver=self.mockserver)%0A        self.assertEqual(len(self.items), 1)%0A

Add simple tests for pipelines.