Scrapy, a fast high-level web crawling & scraping framework for Python.
PY3 fixed scrapy bench command
Mikhail Korobov80c55f19a143
diff --git a/scrapy/utils/benchserver.py b/scrapy/utils/benchserver.pyindex 4385d72a9..a9a2c938e 100644--- a/scrapy/utils/benchserver.py+++ b/scrapy/utils/benchserver.py@@ -16,15 +16,15 @@ class Root(Resource):total = _getarg(request, 'total', 100, int)show = _getarg(request, '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'] = nlargstr = 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):diff --git a/tests/test_commands.py b/tests/test_commands.pyindex 5755b3881..057112d12 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)os.mknod(join(self.tmpl_proj, 'root_template'))@@ -276,3 +276,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)