mirror of https://github.com/scrapy/scrapy.git
py3: fix EngineTest.test_crawler
This commit is contained in:
parent
56b69d2ea8
commit
a32b59ac75
|
|
@ -55,11 +55,12 @@ class TestSpider(Spider):
|
|||
|
||||
def parse_item(self, response):
|
||||
item = self.item_cls()
|
||||
m = self.name_re.search(response.body)
|
||||
body = response.body_as_unicode()
|
||||
m = self.name_re.search(body)
|
||||
if m:
|
||||
item['name'] = m.group(1)
|
||||
item['url'] = response.url
|
||||
m = self.price_re.search(response.body)
|
||||
m = self.price_re.search(body)
|
||||
if m:
|
||||
item['price'] = m.group(1)
|
||||
return item
|
||||
|
|
@ -77,8 +78,8 @@ class DictItemsSpider(TestSpider):
|
|||
def start_test_site(debug=False):
|
||||
root_dir = os.path.join(tests_datadir, "test_site")
|
||||
r = static.File(root_dir)
|
||||
r.putChild("redirect", util.Redirect("/redirected"))
|
||||
r.putChild("redirected", static.Data("Redirected here", "text/plain"))
|
||||
r.putChild(b"redirect", util.Redirect(b"/redirected"))
|
||||
r.putChild(b"redirected", static.Data(b"Redirected here", "text/plain"))
|
||||
|
||||
port = reactor.listenTCP(0, server.Site(r), interface="127.0.0.1")
|
||||
if debug:
|
||||
|
|
|
|||
Loading…
Reference in New Issue