summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-06 19:08:59 (GMT)
committerBrett Cannon <brettcannon@users.noreply.github.com>2017-03-06 19:08:59 (GMT)
commitd908fd9ee1c307f7066023eb2031c0f509036cbc (patch)
tree1ab5b2c5a7bf084db1871890c28e096e805ee270 /Lib/test/test_descr.py
parent0f5f1c3055e4c5b3d6165f56507bae6e16af7ca8 (diff)
downloadcpython-d908fd9ee1c307f7066023eb2031c0f509036cbc.zip
cpython-d908fd9ee1c307f7066023eb2031c0f509036cbc.tar.gz
cpython-d908fd9ee1c307f7066023eb2031c0f509036cbc.tar.bz2
bpo-29695: Fixed tests after removing keyword args support in some basic type constructors. (GH-520)
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index c5bff77..5da7ae5 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -2885,14 +2885,19 @@ order (MRO) for bases """
def test_keywords(self):
# Testing keyword args to basic type constructors ...
- self.assertEqual(int(x=1), 1)
- self.assertEqual(float(x=2), 2.0)
- self.assertEqual(int(x=3), 3)
+ with self.assertRaisesRegex(TypeError, 'keyword argument'):
+ int(x=1)
+ with self.assertRaisesRegex(TypeError, 'keyword argument'):
+ float(x=2)
+ with self.assertRaisesRegex(TypeError, 'keyword argument'):
+ bool(x=2)
self.assertEqual(complex(imag=42, real=666), complex(666, 42))
self.assertEqual(str(object=500), '500')
self.assertEqual(str(object=b'abc', errors='strict'), 'abc')
- self.assertEqual(tuple(sequence=range(3)), (0, 1, 2))
- self.assertEqual(list(sequence=(0, 1, 2)), list(range(3)))
+ with self.assertRaisesRegex(TypeError, 'keyword argument'):
+ tuple(sequence=range(3))
+ with self.assertRaisesRegex(TypeError, 'keyword argument'):
+ list(sequence=(0, 1, 2))
# note: as of Python 2.3, dict() no longer has an "items" keyword arg
for constructor in (int, float, int, complex, str, str,
@@ -3447,9 +3452,10 @@ order (MRO) for bases """
# Testing keyword arguments to __init__, __call__...
def f(a): return a
self.assertEqual(f.__call__(a=42), 42)
- a = []
- list.__init__(a, sequence=[0, 1, 2])
- self.assertEqual(a, [0, 1, 2])
+ ba = bytearray()
+ bytearray.__init__(ba, 'abc\xbd\u20ac',
+ encoding='latin1', errors='replace')
+ self.assertEqual(ba, b'abc\xbd?')
def test_recursive_call(self):
# Testing recursive __call__() by setting to instance of class...