mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Issue #28385: An error message when non-empty format spec is passed to
object.__format__ now contains the name of actual type.
This commit is contained in:
parent
c9b750d249
commit
d1af5effc2
3 changed files with 29 additions and 32 deletions
|
@ -1259,6 +1259,15 @@ class AssortedBytesTest(unittest.TestCase):
|
|||
self.assertEqual(f(b"'"), '''b"'"''') # '''
|
||||
self.assertEqual(f(b"'\""), r"""b'\'"'""") # '
|
||||
|
||||
@check_bytes_warnings
|
||||
def test_format(self):
|
||||
for b in b'abc', bytearray(b'abc'):
|
||||
self.assertEqual(format(b), str(b))
|
||||
self.assertEqual(format(b, ''), str(b))
|
||||
with self.assertRaisesRegex(TypeError,
|
||||
r'\b%s\b' % re.escape(type(b).__name__)):
|
||||
format(b, 's')
|
||||
|
||||
def test_compare_bytes_to_bytearray(self):
|
||||
self.assertEqual(b"abc" == bytes(b"abc"), True)
|
||||
self.assertEqual(b"ab" != bytes(b"abc"), True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue