diff -r 63b45c959a2a Lib/test/test_array.py
--- a/Lib/test/test_array.py Sun Nov 04 07:00:04 2012 +0200
+++ b/Lib/test/test_array.py Mon Nov 12 22:27:56 2012 -0800
@@ -837,6 +837,15 @@
self.assertEqual(a.index(x), example.index(x))
self.assertRaises(ValueError, a.index, None)
self.assertRaises(ValueError, a.index, self.outside)
+
+ # test proper failure with error msg
+ # that includes the item that couldn't
+ # be indexed (issue 13349).
+ a = array.array('i',[1,2,3,4,5])
+ item = 6
+ with self.assertRaises(ValueError) as ve:
+ a.index(item)
+ self.assertIn(repr(item), str(ve.exception))
def test_count(self):
example = 2*self.example
@@ -860,6 +869,15 @@
self.assertRaises(ValueError, a.remove, self.outside)
self.assertRaises(ValueError, a.remove, None)
+
+ # test proper failure with error msg
+ # that includes the item that couldn't
+ # be removed (issue 13349).
+ a = array.array('i',[1,2,3,4,5])
+ item = 6
+ with self.assertRaises(ValueError) as ve:
+ a.remove(item)
+ self.assertIn(repr(item), str(ve.exception))
def test_pop(self):
a = array.array(self.typecode)
diff -r 63b45c959a2a Lib/test/test_deque.py
--- a/Lib/test/test_deque.py Sun Nov 04 07:00:04 2012 +0200
+++ b/Lib/test/test_deque.py Mon Nov 12 22:27:56 2012 -0800
@@ -356,6 +356,14 @@
self.assertRaises(IndexError, d.remove, 'c')
self.assertEqual(d, deque())
+ # test proper failure with error msg
+ # that includes the item that couldn't
+ # be removed (issue 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 63b45c959a2a Lib/test/test_list.py
--- a/Lib/test/test_list.py Sun Nov 04 07:00:04 2012 +0200
+++ b/Lib/test/test_list.py Mon Nov 12 22:27:56 2012 -0800
@@ -106,6 +106,38 @@
with self.assertRaises(TypeError):
(3,) + L([1,2])
+ def test_index(self):
+ lst = [1, 2, 3]
+
+ # positive case
+ lst.index(3)
+
+ # test proper failure with error msg
+ # that includes the item that couldn't
+ # be indexed (issue 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]
+
+ # positive case, remove only first occurrence
+ item = 1
+ lst.append(item)
+ lst.remove(item)
+ self.assertEqual(item, lst.pop())
+
+ # test proper failure with error msg
+ # that includes the item that couldn't
+ # be removed (issue 13349).
+ item = 4
+ 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 63b45c959a2a Lib/test/test_tuple.py
--- a/Lib/test/test_tuple.py Sun Nov 04 07:00:04 2012 +0200
+++ b/Lib/test/test_tuple.py Mon Nov 12 22:27:56 2012 -0800
@@ -18,6 +18,36 @@
self.assertEqual(tuple(''), ())
self.assertEqual(tuple('spam'), ('s', 'p', 'a', 'm'))
+ def test_remove(self):
+
+ tpl = ('a', 'b', 'c')
+
+ item = 'a'
+
+ # positive case.
+ tpl.index(item)
+
+ # test proper failure with error msg
+ # that includes the item that couldn't
+ # be indexd (issue 13349) with short
+ # item.
+ item = 't'
+ with self.assertRaises(ValueError) as ve:
+ tpl.index(item)
+ self.assertIn(item, str(ve.exception))
+
+ # test proper failure with error msg
+ # that includes the item that couldn't
+ # be indexd (issue 13349) with long
+ # item longer than 100 chars.
+ 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 63b45c959a2a Lib/test/test_xml_etree.py
--- a/Lib/test/test_xml_etree.py Sun Nov 04 07:00:04 2012 +0200
+++ b/Lib/test/test_xml_etree.py Mon Nov 12 22:27:56 2012 -0800
@@ -261,9 +261,6 @@
>>> element.remove(subelement)
>>> serialize(element) # 5
'