mirror of https://github.com/scrapy/scrapy.git
Add test for DNS cache disabling
This commit is contained in:
parent
dd5ab6c5fe
commit
1f08d9a648
|
|
@ -226,6 +226,27 @@ class MySpider(scrapy.Spider):
|
|||
self.assertNotIn("DEBUG: It Works!", log)
|
||||
self.assertIn("INFO: Spider opened", log)
|
||||
|
||||
def test_runspider_dnscache_disabled(self):
|
||||
# see https://github.com/scrapy/scrapy/issues/2811
|
||||
# The spider below should not be able to connect to localhost:12345,
|
||||
# which is intended,
|
||||
# but this should not be because of DNS lookup error
|
||||
# assumption: localhost will resolve in all cases (true?)
|
||||
log = self.get_log("""
|
||||
import scrapy
|
||||
|
||||
class MySpider(scrapy.Spider):
|
||||
name = 'myspider'
|
||||
start_urls = ['http://localhost:12345']
|
||||
|
||||
def parse(self, response):
|
||||
return {'test': 'value'}
|
||||
""",
|
||||
args=('-s', 'DNSCACHE_ENABLED=False'))
|
||||
print(log)
|
||||
self.assertNotIn("DNSLookupError", log)
|
||||
self.assertIn("INFO: Spider opened", log)
|
||||
|
||||
def test_runspider_log_short_names(self):
|
||||
log1 = self.get_log(self.debug_log_spider,
|
||||
args=('-s', 'LOG_SHORT_NAMES=1'))
|
||||
|
|
|
|||
Loading…
Reference in New Issue