diff --git a/tests/py3-ignores.txt b/tests/py3-ignores.txt index d0f9e9e91..9be3a99a8 100644 --- a/tests/py3-ignores.txt +++ b/tests/py3-ignores.txt @@ -4,7 +4,6 @@ tests/test_command_shell.py tests/test_commands.py tests/test_exporters.py tests/test_linkextractors.py -tests/test_loader.py tests/test_crawl.py tests/test_crawler.py tests/test_downloader_handlers.py diff --git a/tests/requirements-py3.txt b/tests/requirements-py3.txt index a92fdd4a8..8f9e22f0b 100644 --- a/tests/requirements-py3.txt +++ b/tests/requirements-py3.txt @@ -1,3 +1,4 @@ pytest>=2.6.0 pytest-twisted testfixtures +jmespath diff --git a/tests/test_loader.py b/tests/test_loader.py index 6e8f7c0de..8cf5e484a 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -1,4 +1,5 @@ import unittest +import six from functools import partial from scrapy.loader import ItemLoader @@ -141,7 +142,7 @@ class BasicItemLoaderTest(unittest.TestCase): def test_get_value(self): il = NameItemLoader() - self.assertEqual(u'FOO', il.get_value([u'foo', u'bar'], TakeFirst(), unicode.upper)) + self.assertEqual(u'FOO', il.get_value([u'foo', u'bar'], TakeFirst(), six.text_type.upper)) self.assertEqual([u'foo', u'bar'], il.get_value([u'name:foo', u'name:bar'], re=u'name:(.*)$')) self.assertEqual(u'foo', il.get_value([u'name:foo', u'name:bar'], TakeFirst(), re=u'name:(.*)$')) @@ -242,7 +243,7 @@ class BasicItemLoaderTest(unittest.TestCase): def test_extend_custom_input_processors(self): class ChildItemLoader(TestItemLoader): - name_in = MapCompose(TestItemLoader.name_in, unicode.swapcase) + name_in = MapCompose(TestItemLoader.name_in, six.text_type.swapcase) il = ChildItemLoader() il.add_value('name', u'marta') @@ -250,7 +251,7 @@ class BasicItemLoaderTest(unittest.TestCase): def test_extend_default_input_processors(self): class ChildDefaultedItemLoader(DefaultedItemLoader): - name_in = MapCompose(DefaultedItemLoader.default_input_processor, unicode.swapcase) + name_in = MapCompose(DefaultedItemLoader.default_input_processor, six.text_type.swapcase) il = ChildDefaultedItemLoader() il.add_value('name', u'marta') @@ -423,7 +424,7 @@ class ProcessorsTest(unittest.TestCase): self.assertRaises(TypeError, proc, [None, '', 'hello', 'world']) self.assertEqual(proc(['', 'hello', 'world']), u' hello world') self.assertEqual(proc(['hello', 'world']), u'hello world') - self.assert_(isinstance(proc(['hello', 'world']), unicode)) + self.assert_(isinstance(proc(['hello', 'world']), six.text_type)) def test_compose(self): proc = Compose(lambda v: v[0], str.upper) @@ -435,13 +436,13 @@ class ProcessorsTest(unittest.TestCase): def test_mapcompose(self): filter_world = lambda x: None if x == 'world' else x - proc = MapCompose(filter_world, unicode.upper) + proc = MapCompose(filter_world, six.text_type.upper) self.assertEqual(proc([u'hello', u'world', u'this', u'is', u'scrapy']), [u'HELLO', u'THIS', u'IS', u'SCRAPY']) class SelectortemLoaderTest(unittest.TestCase): - response = HtmlResponse(url="", body=""" + response = HtmlResponse(url="", encoding='utf-8', body=b"""
marta