]> granicus.if.org Git - python/commitdiff
test_iterator(): Don't do a type comparison to see if it's an
authorBarry Warsaw <barry@python.org>
Tue, 25 Sep 2001 21:40:04 +0000 (21:40 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 25 Sep 2001 21:40:04 +0000 (21:40 +0000)
iterator, just test to make sure it has the two required iterator
protocol methods __iter__() and next() -- actually just test
hasattr-ness.

Lib/test/test_StringIO.py

index 4a0a814ddd6427cd631bb27378292f2db579d945..33db4ba5bcd7016243d27b453ccc2560390f5628 100644 (file)
@@ -57,8 +57,11 @@ class TestGenericStringIO(unittest.TestCase):
 
     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')