diff options
author | Barry Warsaw <barry@python.org> | 2001-09-25 21:40:04 +0000 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2001-09-25 21:40:04 +0000 |
commit | 0574cdaeb498d9712b8b83a5c0e86abd52cb7a07 (patch) | |
tree | 098e977d864fcea2eec2e62b448024cbee42d1a5 /Lib/test/test_StringIO.py | |
parent | 4286d3bf15ffa944abf7e27cd3913f183dd9d2c5 (diff) | |
download | cpython-0574cdaeb498d9712b8b83a5c0e86abd52cb7a07.tar.gz |
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.
Diffstat (limited to 'Lib/test/test_StringIO.py')
-rw-r--r-- | Lib/test/test_StringIO.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_StringIO.py b/Lib/test/test_StringIO.py index 4a0a814ddd..33db4ba5bc 100644 --- a/Lib/test/test_StringIO.py +++ b/Lib/test/test_StringIO.py @@ -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') |