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.
This commit is contained in:
Barry Warsaw 2001-09-25 21:40:04 +00:00
parent 874f15aa28
commit 45653503ec
1 changed files with 4 additions and 1 deletions

View 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')