mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
#6780: fix starts/endswith error message to mention that tuples are accepted too.
This commit is contained in:
parent
2043f9c582
commit
ba42fd5801
6 changed files with 66 additions and 13 deletions
|
@ -290,6 +290,14 @@ class BaseBytesTest(unittest.TestCase):
|
|||
self.assertTrue(b.startswith(b"h"))
|
||||
self.assertFalse(b.startswith(b"hellow"))
|
||||
self.assertFalse(b.startswith(b"ha"))
|
||||
try:
|
||||
b.startswith([b'h'])
|
||||
except TypeError as err:
|
||||
exc = str(err)
|
||||
else:
|
||||
self.fail('startswith unexpectedly succeeded')
|
||||
self.assertIn('bytes', exc)
|
||||
self.assertIn('tuple', exc)
|
||||
|
||||
def test_endswith(self):
|
||||
b = self.type2test(b'hello')
|
||||
|
@ -299,6 +307,14 @@ class BaseBytesTest(unittest.TestCase):
|
|||
self.assertTrue(b.endswith(b"o"))
|
||||
self.assertFalse(b.endswith(b"whello"))
|
||||
self.assertFalse(b.endswith(b"no"))
|
||||
try:
|
||||
b.endswith([b'o'])
|
||||
except TypeError as err:
|
||||
exc = str(err)
|
||||
else:
|
||||
self.fail('endswith unexpectedly succeeded')
|
||||
self.assertIn('bytes', exc)
|
||||
self.assertIn('tuple', exc)
|
||||
|
||||
def test_find(self):
|
||||
b = self.type2test(b'mississippi')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue