summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-13 19:33:07 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-13 19:33:07 (GMT)
commit808b94eb453603fcfcd6208e0003cfe37ea3f604 (patch)
treeb88f04377a307247d0ff579b2c59357af479bb10 /Lib
parent3f996e7266113eed814015d977d50e221c3a421d (diff)
downloadcpython-808b94eb453603fcfcd6208e0003cfe37ea3f604.zip
cpython-808b94eb453603fcfcd6208e0003cfe37ea3f604.tar.gz
cpython-808b94eb453603fcfcd6208e0003cfe37ea3f604.tar.bz2
Added simple tests of keyword arguments in the basic type constructors.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_descr.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 9324179..ed37ae8 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1694,6 +1694,29 @@ def inherits():
except:
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()
dicts()
@@ -1728,6 +1751,7 @@ def all():
properties()
supers()
inherits()
+ keywords()
all()