mirror of https://github.com/scrapy/scrapy.git
PY3 fix test cmdline
This commit is contained in:
parent
4d41cc0dc4
commit
3e6d6c43ac
|
|
@ -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_classes
|
||||
for 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 obj
|
||||
|
||||
def _get_commands_from_module(module, inproject):
|
||||
|
|
|
|||
|
|
@ -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 = None
|
||||
|
||||
def outReceived(self, data):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
tests/test_closespider.py
|
||||
tests/test_cmdline/__init__.py
|
||||
tests/test_command_fetch.py
|
||||
tests/test_command_shell.py
|
||||
tests/test_commands.py
|
||||
tests/test_command_version.py
|
||||
tests/test_exporters.py
|
||||
tests/test_linkextractors.py
|
||||
tests/test_loader.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_args
|
||||
proc = 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'), \
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import sys
|
||||
from twisted.trial import unittest
|
||||
from twisted.internet import defer
|
||||
|
||||
|
|
@ -11,5 +12,6 @@ class VersionTest(ProcessTest, unittest.TestCase):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def 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__)
|
||||
|
|
|
|||
Loading…
Reference in New Issue