Skip to content

Commit 8138db4

Browse files
Add more tests
1 parent 519e794 commit 8138db4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Lib/test/test_str.py

+18
Original file line numberDiff line numberDiff line change
@@ -2651,6 +2651,24 @@ def test_check_encoding_errors(self):
26512651
proc = assert_python_failure('-X', 'dev', '-c', code)
26522652
self.assertEqual(proc.rc, 10, proc)
26532653

2654+
def test_str_invalid_call(self):
2655+
check = lambda *a, **kw: self.assertRaises(TypeError, str, *a, **kw)
2656+
2657+
# too many args
2658+
check(1, "", "", 1)
2659+
2660+
# no such kw arg
2661+
check(test=1)
2662+
2663+
# 'encoding' must be str
2664+
check(1, encoding=1)
2665+
check(1, 1)
2666+
2667+
# 'errors' must be str
2668+
check(1, errors=1)
2669+
check(1, "", errors=1)
2670+
check(1, 1, 1)
2671+
26542672

26552673
class StringModuleTest(unittest.TestCase):
26562674
def test_formatter_parser(self):

0 commit comments

Comments
 (0)