Skip to content

bpo-29695: Fixed tests after removing keyword args support in some ba… #520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions Lib/test/test_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2885,14 +2885,19 @@ class sublist(list):

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,
Expand Down Expand Up @@ -3447,9 +3452,10 @@ def test_keyword_arguments(self):
# 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...
Expand Down