From 877e345d79c6a14b6ab24a3f15653f6373918cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gra=C3=B1a?= Date: Sat, 8 Feb 2014 16:38:19 -0200 Subject: [PATCH] localhost666 can resolve under certain circumstances localhost666 is resolvable if the host running the tests contains a "search mydomain.com" in /etc/resolv.conf and a wildcard dns entry exists for *.mydomain.com --- scrapy/tests/test_crawl.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scrapy/tests/test_crawl.py b/scrapy/tests/test_crawl.py index f8b54381e..ae068b79c 100644 --- a/scrapy/tests/test_crawl.py +++ b/scrapy/tests/test_crawl.py @@ -1,4 +1,6 @@ import json +import socket +import mock from twisted.internet import defer from twisted.trial.unittest import TestCase from scrapy.utils.test import get_crawler, get_testlog @@ -88,9 +90,11 @@ class CrawlTestCase(TestCase): @defer.inlineCallbacks def test_retry_dns_error(self): - spider = SimpleSpider("http://localhost666/status?n=503") - yield docrawl(spider) - self._assert_retried() + with mock.patch('socket.gethostbyname', + side_effect=socket.gaierror(-5, 'No address associated with hostname')): + spider = SimpleSpider("http://example.com/") + yield docrawl(spider) + self._assert_retried() @defer.inlineCallbacks def test_start_requests_bug_before_yield(self):