mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +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:
commit
7984bff52a
3 changed files with 29 additions and 32 deletions
|
|
@ -1416,6 +1416,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