[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.52,1.53

Tim Peters tim_one@users.sourceforge.net
Thu, 13 Sep 2001 12:33:10 -0700


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

Modified Files:
	test_descr.py 
Log Message:
Added simple tests of keyword arguments in the basic type constructors.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** test_descr.py	2001/09/13 19:18:27	1.52
--- test_descr.py	2001/09/13 19:33:07	1.53
***************
*** 1695,1698 ****
--- 1695,1721 ----
              pass
  
+ def keywords():
+     if verbose:
+         print "Testing keyword args to basic type constructors ..."
+     verify(int(x=1) == 1)
+     verify(float(x=2) == 2.0)
+     verify(long(x=3) == 3L)
+     verify(complex(imag=42, real=666) == complex(666, 42))
+     verify(str(object=500) == '500')
+     verify(unicode(string='abc', errors='strict') == u'abc')
+     verify(tuple(sequence=range(3)) == (0, 1, 2))
+     verify(list(sequence=(0, 1, 2)) == range(3))
+     verify(dictionary(mapping={1: 2}) == {1: 2})
+ 
+     for constructor in (int, float, long, complex, str, unicode,
+                         tuple, list, dictionary, file):
+         try:
+             constructor(bogus_keyword_arg=1)
+         except TypeError:
+             pass
+         else:
+             raise TestFailed("expected TypeError from bogus keyword "
+                              "argument to %r" % constructor)
+             
  def all():
      lists()
***************
*** 1729,1732 ****
--- 1752,1756 ----
      supers()
      inherits()
+     keywords()
  
  all()