diff Lib/test/test_StringIO.py @ 20096:19abc339d3fc legacy-trunk

test_iterator(): Don't do a type comparison to see if it's an iterator, just test to make sure it has the two required iterator protocol methods __iter__() and next() -- actually just test hasattr-ness.
author Barry Warsaw <barry@python.org>
date Tue, 25 Sep 2001 21:40:04 +0000
parents ccec02bfe9a0
children 60df2bf854ac
line wrap: on
line diff
--- a/Lib/test/test_StringIO.py	Tue Sep 25 21:16:33 2001 +0000
+++ b/Lib/test/test_StringIO.py	Tue Sep 25 21:40:04 2001 +0000
@@ -57,8 +57,11 @@
 
     def test_iterator(self):
         eq = self.assertEqual
+        unless = self.failUnless
         it = iter(self._fp)
-        self.failUnless(isinstance(it, types.FunctionIterType))
+        # Does this object support the iteration protocol?
+        unless(hasattr(it, '__iter__'))
+        unless(hasattr(it, 'next'))
         i = 0
         for line in self._fp:
             eq(line, self._line + '\n')