diff -r 1fde0d70f2b8 Lib/test/test_array.py
--- a/Lib/test/test_array.py Fri Nov 09 18:58:47 2012 -0800
+++ b/Lib/test/test_array.py Sat Dec 08 22:58:22 2012 -0800
@@ -838,6 +838,12 @@
self.assertRaises(ValueError, a.index, None)
self.assertRaises(ValueError, a.index, self.outside)
+ # check that the item is included in the message (see #13349)
+ a = array.array(self.typecode, self.example)
+ with self.assertRaises(ValueError) as ve:
+ a.index(self.outside)
+ self.assertIn(repr(self.outside), str(ve.exception))
+
def test_count(self):
example = 2*self.example
a = array.array(self.typecode, example)
@@ -861,6 +867,12 @@
self.assertRaises(ValueError, a.remove, None)
+ # check that the item is included in the message (see #13349)
+ a = array.array(self.typecode, self.example)
+ with self.assertRaises(ValueError) as ve:
+ a.remove(self.outside)
+ self.assertIn(repr(self.outside), str(ve.exception))
+
def test_pop(self):
a = array.array(self.typecode)
self.assertRaises(IndexError, a.pop)
diff -r 1fde0d70f2b8 Lib/test/test_deque.py
--- a/Lib/test/test_deque.py Fri Nov 09 18:58:47 2012 -0800
+++ b/Lib/test/test_deque.py Sat Dec 08 22:58:22 2012 -0800
@@ -356,6 +356,12 @@
self.assertRaises(IndexError, d.remove, 'c')
self.assertEqual(d, deque())
+ # check that the item is included in the message (see #13349)
+ item = 't'
+ with self.assertRaises(ValueError) as ve:
+ d.remove(item)
+ self.assertIn(item, str(ve.exception))
+
def test_repr(self):
d = deque(range(200))
e = eval(repr(d))
diff -r 1fde0d70f2b8 Lib/test/test_list.py
--- a/Lib/test/test_list.py Fri Nov 09 18:58:47 2012 -0800
+++ b/Lib/test/test_list.py Sat Dec 08 22:58:22 2012 -0800
@@ -106,6 +106,32 @@
with self.assertRaises(TypeError):
(3,) + L([1,2])
+ def test_index(self):
+ lst = [1, 2, 3]
+ idx = lst.index(1)
+ self.assertEqual(idx,0)
+
+ # check that the item is included in the message (see #13349)
+ item = 17
+ with self.assertRaises(ValueError) as ve:
+ lst.index(item)
+ self.assertIn(str(item), str(ve.exception))
+
+ def test_remove(self):
+ lst = [1, 2, 3, 4]
+ lst.append(1)
+ lst.remove(1)
+ self.assertEqual(1, lst[len(lst)-1])
+
+ lst.remove(4)
+ self.assertNotIn(4,lst)
+
+ # check that the item is included in the message (see #13349)
+ item = 99
+ with self.assertRaises(ValueError) as ve:
+ lst.remove(item)
+ self.assertIn(str(item), str(ve.exception))
+
def test_main(verbose=None):
support.run_unittest(ListTest)
diff -r 1fde0d70f2b8 Lib/test/test_tuple.py
--- a/Lib/test/test_tuple.py Fri Nov 09 18:58:47 2012 -0800
+++ b/Lib/test/test_tuple.py Sat Dec 08 22:58:22 2012 -0800
@@ -18,6 +18,25 @@
self.assertEqual(tuple(''), ())
self.assertEqual(tuple('spam'), ('s', 'p', 'a', 'm'))
+ def test_index(self):
+
+ tpl = ('a', 'b', 'c')
+ self.assertEqual(0, tpl.index('a'))
+
+ # check that the item is included in the message (see #13349)
+ item = 'SomeItem'
+ with self.assertRaises(ValueError) as ve:
+ tpl.index(item)
+ self.assertIn(item, str(ve.exception))
+
+ # check that the item is included in the message (see #13349)
+ msg_fmt_len = len('tuple.index(..): element not in tuple')
+ item = " ".join([str(i) for i in range(1000)])
+ with self.assertRaises(ValueError) as ve:
+ tpl.index(item)
+ self.assertIn(item[:99], str(ve.exception))
+ self.assertGreaterEqual(100 + msg_fmt_len, len(str(ve.exception)))
+
def test_truth(self):
super().test_truth()
self.assertTrue(not ())
diff -r 1fde0d70f2b8 Lib/test/test_xml_etree.py
--- a/Lib/test/test_xml_etree.py Fri Nov 09 18:58:47 2012 -0800
+++ b/Lib/test/test_xml_etree.py Sat Dec 08 22:58:22 2012 -0800
@@ -261,9 +261,6 @@
>>> element.remove(subelement)
>>> serialize(element) # 5
'