mirror of
https://github.com/python/cpython.git
synced 2025-08-16 23:01:34 +00:00
#6780: fix starts/endswith error message to mention that tuples are accepted too.
This commit is contained in:
parent
a0895db2e1
commit
e3685f6b1b
5 changed files with 46 additions and 6 deletions
|
@ -414,7 +414,18 @@ class StrTest(
|
|||
self.assertEqual('Andr\202 x'.decode('ascii', 'replace'),
|
||||
'Andr\202 x'.decode(encoding='ascii', errors='replace'))
|
||||
|
||||
|
||||
def test_startswith_endswith_errors(self):
|
||||
with self.assertRaises(UnicodeDecodeError):
|
||||
'\xff'.startswith(u'x')
|
||||
with self.assertRaises(UnicodeDecodeError):
|
||||
'\xff'.endswith(u'x')
|
||||
for meth in ('foo'.startswith, 'foo'.endswith):
|
||||
with self.assertRaises(TypeError) as cm:
|
||||
meth(['f'])
|
||||
exc = str(cm.exception)
|
||||
self.assertIn('unicode', exc)
|
||||
self.assertIn('str', exc)
|
||||
self.assertIn('tuple', exc)
|
||||
|
||||
def test_main():
|
||||
test_support.run_unittest(StrTest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue