Scrapy, a fast high-level web crawling & scraping framework for Python.
PY3 fix test cmdline
nyov3e6d6c43ac07
diff --git a/scrapy/cmdline.py b/scrapy/cmdline.pyindex a619c349a..35050c13d 100644--- a/scrapy/cmdline.py+++ b/scrapy/cmdline.py@@ -18,10 +18,10 @@ def _iter_command_classes(module_name):# TODO: add `name` attribute to commands and and merge this function with# scrapy.utils.spider.iter_spider_classesfor module in walk_modules(module_name):- for obj in vars(module).itervalues():+ for obj in vars(module).values():if inspect.isclass(obj) and \- issubclass(obj, ScrapyCommand) and \- obj.__module__ == module.__name__:+ issubclass(obj, ScrapyCommand) and \+ obj.__module__ == module.__name__:yield objdef _get_commands_from_module(module, inproject):diff --git a/scrapy/utils/testproc.py b/scrapy/utils/testproc.pyindex adddad093..f268e91ff 100644--- a/scrapy/utils/testproc.py+++ b/scrapy/utils/testproc.py@@ -35,8 +35,8 @@ class TestProcessProtocol(protocol.ProcessProtocol):def __init__(self):self.deferred = defer.Deferred()- self.out = ''- self.err = ''+ self.out = b''+ self.err = b''self.exitcode = Nonedef outReceived(self, data):diff --git a/tests/py3-ignores.txt b/tests/py3-ignores.txtindex 038f715a6..d0f9e9e91 100644--- a/tests/py3-ignores.txt+++ b/tests/py3-ignores.txt@@ -1,9 +1,7 @@tests/test_closespider.py-tests/test_cmdline/__init__.pytests/test_command_fetch.pytests/test_command_shell.pytests/test_commands.py-tests/test_command_version.pytests/test_exporters.pytests/test_linkextractors.pytests/test_loader.pydiff --git a/tests/test_cmdline/__init__.py b/tests/test_cmdline/__init__.pyindex 00fce2fbc..28ba76827 100644--- a/tests/test_cmdline/__init__.py+++ b/tests/test_cmdline/__init__.py@@ -11,10 +11,11 @@ class CmdlineTest(unittest.TestCase):self.env['SCRAPY_SETTINGS_MODULE'] = 'tests.test_cmdline.settings'def _execute(self, *new_args, **kwargs):+ encoding = getattr(sys.stdout, 'encoding') or 'utf-8'args = (sys.executable, '-m', 'scrapy.cmdline') + new_argsproc = Popen(args, stdout=PIPE, stderr=PIPE, env=self.env, **kwargs)- comm = proc.communicate()- return comm[0].strip()+ comm = proc.communicate()[0].strip()+ return comm.decode(encoding)def test_default_settings(self):self.assertEqual(self._execute('settings', '--get', 'TEST1'), \diff --git a/tests/test_command_version.py b/tests/test_command_version.pyindex 6f0380d77..420713d87 100644--- a/tests/test_command_version.py+++ b/tests/test_command_version.py@@ -1,3 +1,4 @@+import sysfrom twisted.trial import unittestfrom twisted.internet import defer@@ -11,5 +12,6 @@ class VersionTest(ProcessTest, unittest.TestCase):@defer.inlineCallbacksdef test_output(self):+ encoding = getattr(sys.stdout, 'encoding') or 'utf-8'_, out, _ = yield self.execute([])- self.assertEqual(out.strip(), "Scrapy %s" % scrapy.__version__)+ self.assertEqual(out.strip().decode(encoding), "Scrapy %s" % scrapy.__version__)