Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Make DNS retry test compatible with Twisted 17+

Paul Tremberth3358254c5c78
diff --git a/tests/test_crawl.py b/tests/test_crawl.py
index 1b4a4b3b0..c7f4c0e35 100644
--- a/tests/test_crawl.py
+++ b/tests/test_crawl.py
@@ -91,12 +91,11 @@ class CrawlTestCase(TestCase):
@defer.inlineCallbacks
def test_retry_dns_error(self):
- with mock.patch('socket.gethostbyname',
- side_effect=socket.gaierror(-5, 'No address associated with hostname')):
- crawler = self.runner.create_crawler(SimpleSpider)
- with LogCapture() as l:
- yield crawler.crawl("http://example.com/")
- self._assert_retried(l)
+ crawler = self.runner.create_crawler(SimpleSpider)
+ with LogCapture() as l:
+ # try to fetch the homepage of a non-existent domain
+ yield crawler.crawl("http://dns.resolution.invalid/")
+ self._assert_retried(l)
@defer.inlineCallbacks
def test_start_requests_bug_before_yield(self):