diff --git a/scrapy/utils/benchserver.py b/scrapy/utils/benchserver.py
index 4385d72a9..5bbda6e27 100644
--- a/scrapy/utils/benchserver.py
+++ b/scrapy/utils/benchserver.py
@@ -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("
")
+ request.write(b"")
args = request.args.copy()
for nl in nlist:
args['n'] = nl
argstr = urlencode(args, doseq=True)
request.write("follow {1}
"
- .format(argstr, nl))
- request.write("")
- return ''
+ .format(argstr, nl).encode('utf8'))
+ request.write(b"")
+ return b''
def _getarg(request, name, default=None, type=str):
diff --git a/tests/test_commands.py b/tests/test_commands.py
index aa1b7cc7a..a5230eb13 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -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)