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
This commit is contained in:
Daniel Graña 2014-02-08 16:38:19 -02:00
parent 45c9dab15b
commit 877e345d79
1 changed files with 7 additions and 3 deletions

View File

@ -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):