Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

[itemloader-errors] added test for Compose and MapCompose

Mabel Villalbaa753ea7e161e
diff --git a/tests/test_loader.py b/tests/test_loader.py
index 230242592..0f9070b8c 100644
--- a/tests/test_loader.py
+++ b/tests/test_loader.py
@@ -483,12 +483,21 @@ class ProcessorsTest(unittest.TestCase):
self.assertEqual(proc(None), None)
proc = Compose(str.upper, stop_on_none=False)
self.assertRaises(ValueError, proc, None)
+ proc = Compose(str.upper, lambda x: x + 1)
+ self.assertRaises(ValueError, proc, 'hello')
def test_mapcompose(self):
filter_world = lambda x: None if x == 'world' else x
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'])
+ proc = MapCompose(filter_world, six.text_type.upper)
+ self.assertEqual(proc(None), [])
+ proc = MapCompose(filter_world, six.text_type.upper)
+ self.assertRaises(ValueError, proc, [1])
+ proc = MapCompose(filter_world, lambda x: x + 1)
+ self.assertRaises(ValueError, proc, 'hello')
+
class SelectortemLoaderTest(unittest.TestCase):