Skip to content

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

Add tests for MutableChain

Eugenio Lacuestae0360e5223b6
diff --git a/tests/test_utils_python.py b/tests/test_utils_python.py
index f6133657b..3e1148354 100644
--- a/tests/test_utils_python.py
+++ b/tests/test_utils_python.py
@@ -9,11 +9,23 @@ import six
from scrapy.utils.python import (
memoizemethod_noargs, binary_is_text, equal_attributes,
WeakKeyCache, stringify_dict, get_func_args, to_bytes, to_unicode,
- without_none_values)
+ without_none_values, MutableChain)
__doctests__ = ['scrapy.utils.python']
+class MutableChainTest(unittest.TestCase):
+ def test_mutablechain(self):
+ m = MutableChain(range(2), [2, 3], (4, 5))
+ m.extend(range(6, 7))
+ m.extend([7, 8])
+ m.extend([9, 10], (11, 12))
+ self.assertEqual(next(m), 0)
+ self.assertEqual(m.next(), 1)
+ self.assertEqual(m.__next__(), 2)
+ self.assertEqual(list(m), list(range(3, 13)))
+
+
class ToUnicodeTest(unittest.TestCase):
def test_converting_an_utf8_encoded_string_to_unicode(self):
self.assertEqual(to_unicode(b'lel\xc3\xb1e'), u'lel\xf1e')