[Python-checkins] python/dist/src/Lib/test test_sets.py,1.13,1.14
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
2002年11月07日 21:03:23 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv11467/test
Modified Files:
test_sets.py
Log Message:
Closes SF bug #628246.
The _update method detected mutable elements by trapping TypeErrors.
Unfortunately, this masked useful TypeErrors raised by the iterable
itself. For cases where it is possible for an iterable to raise
a TypeError, the iterable is pre-converted to a list outside the
try/except so that any TypeErrors propagate through.
Index: test_sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sets.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** test_sets.py 25 Aug 2002 18:43:10 -0000 1.13
--- test_sets.py 8 Nov 2002 05:03:21 -0000 1.14
***************
*** 133,136 ****
--- 133,160 ----
#==============================================================================
+ def baditer():
+ raise TypeError
+ yield True
+
+ def gooditer():
+ yield True
+
+ class TestExceptionPropagation(unittest.TestCase):
+ """SF 628246: Set constructor should not trap iterator TypeErrors"""
+
+ def test_instanceWithException(self):
+ self.assertRaises(TypeError, Set, baditer())
+
+ def test_instancesWithoutException(self):
+ """All of these iterables should load without exception."""
+ Set([1,2,3])
+ Set((1,2,3))
+ Set({'one':1, 'two':2, 'three':3})
+ Set(xrange(3))
+ Set('abc')
+ Set(gooditer())
+
+ #==============================================================================
+
class TestSetOfSets(unittest.TestCase):
def test_constructor(self):
***************
*** 605,608 ****
--- 629,633 ----
suite = unittest.TestSuite()
for klass in (TestSetOfSets,
+ TestExceptionPropagation,
TestBasicOpsEmpty,
TestBasicOpsSingleton,