[Python-checkins] python/dist/src/Lib/test test_call.py, 1.4, 1.5 test_types.py, 1.58, 1.59 test_userdict.py, 1.17, 1.18

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Thu Mar 4 03:25:46 EST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14562/Lib/test

Modified Files:
	test_call.py test_types.py test_userdict.py 
Log Message:
SF #904720:  dict.update should take a 2-tuple sequence like dict.__init_
(Championed by Bob Ippolito.)

The update() method for mappings now accepts all the same argument forms
as the dict() constructor.  This includes item lists and/or keyword
arguments.



Index: test_call.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_call.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_call.py	1 May 2003 17:45:34 -0000	1.4
--- test_call.py	4 Mar 2004 08:25:44 -0000	1.5
***************
*** 87,101 ****
  
      def test_oldargs1_0(self):
!         self.assertRaises(TypeError, {}.update)
  
      def test_oldargs1_1(self):
!         {}.update({})
  
      def test_oldargs1_2(self):
!         self.assertRaises(TypeError, {}.update, {}, 1)
  
      def test_oldargs1_0_ext(self):
          try:
!             {}.update(*())
          except TypeError:
              pass
--- 87,101 ----
  
      def test_oldargs1_0(self):
!         self.assertRaises(TypeError, [].count)
  
      def test_oldargs1_1(self):
!         [].count(1)
  
      def test_oldargs1_2(self):
!         self.assertRaises(TypeError, [].count, 1, 2)
  
      def test_oldargs1_0_ext(self):
          try:
!             [].count(*())
          except TypeError:
              pass
***************
*** 104,112 ****
  
      def test_oldargs1_1_ext(self):
!         {}.update(*({},))
  
      def test_oldargs1_2_ext(self):
          try:
!             {}.update(*({}, 2))
          except TypeError:
              pass
--- 104,112 ----
  
      def test_oldargs1_1_ext(self):
!         [].count(*(1,))
  
      def test_oldargs1_2_ext(self):
          try:
!             [].count(*(1, 2))
          except TypeError:
              pass
***************
*** 115,125 ****
  
      def test_oldargs1_0_kw(self):
!         self.assertRaises(TypeError, {}.update, x=2)
  
      def test_oldargs1_1_kw(self):
!         self.assertRaises(TypeError, {}.update, {}, x=2)
  
      def test_oldargs1_2_kw(self):
!         self.assertRaises(TypeError, {}.update, x=2, y=2)
  
  
--- 115,125 ----
  
      def test_oldargs1_0_kw(self):
!         self.assertRaises(TypeError, [].count, x=2)
  
      def test_oldargs1_1_kw(self):
!         self.assertRaises(TypeError, [].count, {}, x=2)
  
      def test_oldargs1_2_kw(self):
!         self.assertRaises(TypeError, [].count, x=2, y=2)
  
  

Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** test_types.py	12 Feb 2004 17:35:11 -0000	1.58
--- test_types.py	4 Mar 2004 08:25:44 -0000	1.59
***************
*** 254,258 ****
  d.clear()
  try: d.update(None)
! except AttributeError: pass
  else: raise TestFailed, 'dict.update(None), AttributeError expected'
  class SimpleUserDict:
--- 254,258 ----
  d.clear()
  try: d.update(None)
! except (TypeError, AttributeError): pass
  else: raise TestFailed, 'dict.update(None), AttributeError expected'
  class SimpleUserDict:

Index: test_userdict.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userdict.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** test_userdict.py	16 Nov 2003 16:17:48 -0000	1.17
--- test_userdict.py	4 Mar 2004 08:25:44 -0000	1.18
***************
*** 94,99 ****
          p.update(self.reference)
          self.assertEqual(dict(p), self.reference)
          d = self._full_mapping(self.reference)
!         #setdefaullt
          key, value = d.iteritems().next()
          knownkey, knownvalue = self.other.iteritems().next()
--- 94,103 ----
          p.update(self.reference)
          self.assertEqual(dict(p), self.reference)
+         items = p.items()
+         p = self._empty_mapping()
+         p.update(items)
+         self.assertEqual(dict(p), self.reference)
          d = self._full_mapping(self.reference)
!         #setdefault
          key, value = d.iteritems().next()
          knownkey, knownvalue = self.other.iteritems().next()




More information about the Python-checkins mailing list