Add CrawlerProcess tests for ASYNCIO_ENABLED.

This commit is contained in:
Andrey Rakhmatullin 2019-12-13 18:12:07 +05:00
parent 855bbebc8b
commit bfb78b8dea
3 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import scrapy
from scrapy.crawler import CrawlerProcess
class NoRequestsSpider(scrapy.Spider):
name = 'no_request'
def start_requests(self):
return []
process = CrawlerProcess(settings={
'ASYNCIO_ENABLED': True,
})
process.crawl(NoRequestsSpider)
process.start()

View File

@ -0,0 +1,22 @@
import asyncio
from twisted.internet import asyncioreactor
asyncioreactor.install(asyncio.get_event_loop())
import scrapy
from scrapy.crawler import CrawlerProcess
class NoRequestsSpider(scrapy.Spider):
name = 'no_request'
def start_requests(self):
return []
process = CrawlerProcess(settings={
'ASYNCIO_ENABLED': True,
})
process.crawl(NoRequestsSpider)
process.start()

View File

@ -301,3 +301,14 @@ class CrawlerProcessSubprocess(unittest.TestCase):
def test_simple(self):
log = self.run_script('simple.py')
self.assertIn('Spider closed (finished)', log)
self.assertNotIn("DEBUG: Asyncio support enabled", log)
def test_asyncio_enabled_no_reactor(self):
log = self.run_script('asyncio_enabled_no_reactor.py')
self.assertIn('Spider closed (finished)', log)
self.assertIn("DEBUG: Asyncio support enabled", log)
def test_asyncio_enabled_reactor(self):
log = self.run_script('asyncio_enabled_reactor.py')
self.assertIn('Spider closed (finished)', log)
self.assertIn("DEBUG: Asyncio support enabled", log)