diff Lib/test/test_unicode.py @ 39544:01034018e8b2

Make the it_index field in the str/unicode iterators Py_ssize_t's. Test the new iterators on str/unicode.
author Guido van Rossum <guido@python.org>
date Thu, 17 Aug 2006 21:11:47 +0000
parents 29ae5e0fc348
children cc992d75d5b3
line wrap: on
line diff
--- a/Lib/test/test_unicode.py	Thu Aug 17 20:24:18 2006 +0000
+++ b/Lib/test/test_unicode.py	Thu Aug 17 21:11:47 2006 +0000
@@ -93,6 +93,14 @@
             testrepr = repr(u''.join(map(unichr, xrange(256))))
             self.assertEqual(testrepr, latin1repr)
 
+    def test_iterators(self):
+        # Make sure unicode objects have an __iter__ method
+        it = u"\u1111\u2222\u3333".__iter__()
+        self.assertEqual(it.next(), u"\u1111")
+        self.assertEqual(it.next(), u"\u2222")
+        self.assertEqual(it.next(), u"\u3333")
+        self.assertRaises(StopIteration, it.next)
+
     def test_count(self):
         string_tests.CommonTest.test_count(self)
         # check mixed argument types