mirror of
https://github.com/python/cpython.git
synced 2025-11-03 19:34:08 +00:00
bpo-29695: Fixed tests after removing keyword args support in some basic type constructors. (GH-520)
This commit is contained in:
parent
0f5f1c3055
commit
d908fd9ee1
1 changed files with 14 additions and 8 deletions
|
|
@ -2885,14 +2885,19 @@ order (MRO) for bases """
|
||||||
|
|
||||||
def test_keywords(self):
|
def test_keywords(self):
|
||||||
# Testing keyword args to basic type constructors ...
|
# Testing keyword args to basic type constructors ...
|
||||||
self.assertEqual(int(x=1), 1)
|
with self.assertRaisesRegex(TypeError, 'keyword argument'):
|
||||||
self.assertEqual(float(x=2), 2.0)
|
int(x=1)
|
||||||
self.assertEqual(int(x=3), 3)
|
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(complex(imag=42, real=666), complex(666, 42))
|
||||||
self.assertEqual(str(object=500), '500')
|
self.assertEqual(str(object=500), '500')
|
||||||
self.assertEqual(str(object=b'abc', errors='strict'), 'abc')
|
self.assertEqual(str(object=b'abc', errors='strict'), 'abc')
|
||||||
self.assertEqual(tuple(sequence=range(3)), (0, 1, 2))
|
with self.assertRaisesRegex(TypeError, 'keyword argument'):
|
||||||
self.assertEqual(list(sequence=(0, 1, 2)), list(range(3)))
|
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
|
# note: as of Python 2.3, dict() no longer has an "items" keyword arg
|
||||||
|
|
||||||
for constructor in (int, float, int, complex, str, str,
|
for constructor in (int, float, int, complex, str, str,
|
||||||
|
|
@ -3447,9 +3452,10 @@ order (MRO) for bases """
|
||||||
# Testing keyword arguments to __init__, __call__...
|
# Testing keyword arguments to __init__, __call__...
|
||||||
def f(a): return a
|
def f(a): return a
|
||||||
self.assertEqual(f.__call__(a=42), 42)
|
self.assertEqual(f.__call__(a=42), 42)
|
||||||
a = []
|
ba = bytearray()
|
||||||
list.__init__(a, sequence=[0, 1, 2])
|
bytearray.__init__(ba, 'abc\xbd\u20ac',
|
||||||
self.assertEqual(a, [0, 1, 2])
|
encoding='latin1', errors='replace')
|
||||||
|
self.assertEqual(ba, b'abc\xbd?')
|
||||||
|
|
||||||
def test_recursive_call(self):
|
def test_recursive_call(self):
|
||||||
# Testing recursive __call__() by setting to instance of class...
|
# Testing recursive __call__() by setting to instance of class...
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue