Skip to content

Commit d908fd9

Browse files
serhiy-storchakabrettcannon
authored andcommitted
bpo-29695: Fixed tests after removing keyword args support in some basic type constructors. (GH-520)
1 parent 0f5f1c3 commit d908fd9

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Lib/test/test_descr.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,14 +2885,19 @@ class sublist(list):
28852885

28862886
def test_keywords(self):
28872887
# Testing keyword args to basic type constructors ...
2888-
self.assertEqual(int(x=1), 1)
2889-
self.assertEqual(float(x=2), 2.0)
2890-
self.assertEqual(int(x=3), 3)
2888+
with self.assertRaisesRegex(TypeError, 'keyword argument'):
2889+
int(x=1)
2890+
with self.assertRaisesRegex(TypeError, 'keyword argument'):
2891+
float(x=2)
2892+
with self.assertRaisesRegex(TypeError, 'keyword argument'):
2893+
bool(x=2)
28912894
self.assertEqual(complex(imag=42, real=666), complex(666, 42))
28922895
self.assertEqual(str(object=500), '500')
28932896
self.assertEqual(str(object=b'abc', errors='strict'), 'abc')
2894-
self.assertEqual(tuple(sequence=range(3)), (0, 1, 2))
2895-
self.assertEqual(list(sequence=(0, 1, 2)), list(range(3)))
2897+
with self.assertRaisesRegex(TypeError, 'keyword argument'):
2898+
tuple(sequence=range(3))
2899+
with self.assertRaisesRegex(TypeError, 'keyword argument'):
2900+
list(sequence=(0, 1, 2))
28962901
# note: as of Python 2.3, dict() no longer has an "items" keyword arg
28972902

28982903
for constructor in (int, float, int, complex, str, str,
@@ -3447,9 +3452,10 @@ def test_keyword_arguments(self):
34473452
# Testing keyword arguments to __init__, __call__...
34483453
def f(a): return a
34493454
self.assertEqual(f.__call__(a=42), 42)
3450-
a = []
3451-
list.__init__(a, sequence=[0, 1, 2])
3452-
self.assertEqual(a, [0, 1, 2])
3455+
ba = bytearray()
3456+
bytearray.__init__(ba, 'abc\xbd\u20ac',
3457+
encoding='latin1', errors='replace')
3458+
self.assertEqual(ba, b'abc\xbd?')
34533459

34543460
def test_recursive_call(self):
34553461
# Testing recursive __call__() by setting to instance of class...

0 commit comments

Comments
 (0)