Skip to content

Commit 3e6d6c4

Browse files
nyovkmike
authored andcommitted
PY3 fix test cmdline
1 parent 4d41cc0 commit 3e6d6c4

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

scrapy/cmdline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def _iter_command_classes(module_name):
1818
# TODO: add `name` attribute to commands and and merge this function with
1919
# scrapy.utils.spider.iter_spider_classes
2020
for module in walk_modules(module_name):
21-
for obj in vars(module).itervalues():
21+
for obj in vars(module).values():
2222
if inspect.isclass(obj) and \
23-
issubclass(obj, ScrapyCommand) and \
24-
obj.__module__ == module.__name__:
23+
issubclass(obj, ScrapyCommand) and \
24+
obj.__module__ == module.__name__:
2525
yield obj
2626

2727
def _get_commands_from_module(module, inproject):

scrapy/utils/testproc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class TestProcessProtocol(protocol.ProcessProtocol):
3535

3636
def __init__(self):
3737
self.deferred = defer.Deferred()
38-
self.out = ''
39-
self.err = ''
38+
self.out = b''
39+
self.err = b''
4040
self.exitcode = None
4141

4242
def outReceived(self, data):

tests/py3-ignores.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
tests/test_closespider.py
2-
tests/test_cmdline/__init__.py
32
tests/test_command_fetch.py
43
tests/test_command_shell.py
54
tests/test_commands.py
6-
tests/test_command_version.py
75
tests/test_exporters.py
86
tests/test_linkextractors.py
97
tests/test_loader.py

tests/test_cmdline/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ def setUp(self):
1111
self.env['SCRAPY_SETTINGS_MODULE'] = 'tests.test_cmdline.settings'
1212

1313
def _execute(self, *new_args, **kwargs):
14+
encoding = getattr(sys.stdout, 'encoding') or 'utf-8'
1415
args = (sys.executable, '-m', 'scrapy.cmdline') + new_args
1516
proc = Popen(args, stdout=PIPE, stderr=PIPE, env=self.env, **kwargs)
16-
comm = proc.communicate()
17-
return comm[0].strip()
17+
comm = proc.communicate()[0].strip()
18+
return comm.decode(encoding)
1819

1920
def test_default_settings(self):
2021
self.assertEqual(self._execute('settings', '--get', 'TEST1'), \

tests/test_command_version.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from twisted.trial import unittest
23
from twisted.internet import defer
34

@@ -11,5 +12,6 @@ class VersionTest(ProcessTest, unittest.TestCase):
1112

1213
@defer.inlineCallbacks
1314
def test_output(self):
15+
encoding = getattr(sys.stdout, 'encoding') or 'utf-8'
1416
_, out, _ = yield self.execute([])
15-
self.assertEqual(out.strip(), "Scrapy %s" % scrapy.__version__)
17+
self.assertEqual(out.strip().decode(encoding), "Scrapy %s" % scrapy.__version__)

0 commit comments

Comments
 (0)