mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-23 15:43:47 +00:00
Merge pull request #1708 from scrapy/fix-scrapy-bench
PY3 fixed scrapy bench command
This commit is contained in:
commit
0f500a1f82
@ -13,18 +13,18 @@ class Root(Resource):
|
||||
return self
|
||||
|
||||
def render(self, request):
|
||||
total = _getarg(request, 'total', 100, int)
|
||||
show = _getarg(request, 'show', 10, int)
|
||||
total = _getarg(request, b'total', 100, int)
|
||||
show = _getarg(request, b'show', 10, int)
|
||||
nlist = [random.randint(1, total) for _ in range(show)]
|
||||
request.write("<html><head></head><body>")
|
||||
request.write(b"<html><head></head><body>")
|
||||
args = request.args.copy()
|
||||
for nl in nlist:
|
||||
args['n'] = nl
|
||||
argstr = urlencode(args, doseq=True)
|
||||
request.write("<a href='/follow?{0}'>follow {1}</a><br>"
|
||||
.format(argstr, nl))
|
||||
request.write("</body></html>")
|
||||
return ''
|
||||
.format(argstr, nl).encode('utf8'))
|
||||
request.write(b"</body></html>")
|
||||
return b''
|
||||
|
||||
|
||||
def _getarg(request, name, default=None, type=str):
|
||||
|
@ -72,7 +72,7 @@ class StartprojectTest(ProjectTest):
|
||||
self.assertEqual(1, self.call('startproject', self.project_name))
|
||||
self.assertEqual(1, self.call('startproject', 'wrong---project---name'))
|
||||
self.assertEqual(1, self.call('startproject', 'sys'))
|
||||
|
||||
|
||||
|
||||
class StartprojectTemplatesTest(ProjectTest):
|
||||
|
||||
@ -80,7 +80,7 @@ class StartprojectTemplatesTest(ProjectTest):
|
||||
super(StartprojectTemplatesTest, self).setUp()
|
||||
self.tmpl = join(self.temp_path, 'templates')
|
||||
self.tmpl_proj = join(self.tmpl, 'project')
|
||||
|
||||
|
||||
def test_startproject_template_override(self):
|
||||
copytree(join(scrapy.__path__[0], 'templates'), self.tmpl)
|
||||
with open(join(self.tmpl_proj, 'root_template'), 'w'):
|
||||
@ -277,3 +277,4 @@ class BenchCommandTest(CommandTest):
|
||||
'-s', 'CLOSESPIDER_TIMEOUT=0.01')
|
||||
log = to_native_str(p.stderr.read())
|
||||
self.assertIn('INFO: Crawled', log)
|
||||
self.assertNotIn('Unhandled Error', log)
|
||||
|
Loading…
x
Reference in New Issue
Block a user