[Python-checkins] python/dist/src/Lib/test test_array.py,1.21,1.22

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Sat, 17 May 2003 20:15:11 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv18431/Lib/test

Modified Files:
	test_array.py 
Log Message:
Fix array.array.insert(), so that it treats negative indices as
being relative to the end of the array, just like list.insert() does.
This closes SF bug #739313.


Index: test_array.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** test_array.py	18 May 2003 01:56:25 -0000	1.21
--- test_array.py	18 May 2003 03:15:08 -0000	1.22
***************
*** 83,86 ****
--- 83,110 ----
          self.assertRaises(TypeError, a.insert, 0, None)
  
+         a = array.array(self.typecode, self.example)
+         a.insert(-1, self.example[0])
+         self.assertEqual(
+             a,
+             array.array(
+                 self.typecode,
+                 self.example[:-1] + self.example[:1] + self.example[-1:]
+             )
+         )
+ 
+         a = array.array(self.typecode, self.example)
+         a.insert(-1000, self.example[0])
+         self.assertEqual(
+             a,
+             array.array(self.typecode, self.example[:1] + self.example)
+         )
+ 
+         a = array.array(self.typecode, self.example)
+         a.insert(1000, self.example[0])
+         self.assertEqual(
+             a,
+             array.array(self.typecode, self.example + self.example[:1])
+         )
+ 
      def test_tofromfile(self):
          a = array.array(self.typecode, 2*self.example)