summaryrefslogtreecommitdiff
path: root/Lib/test/test_bytes.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-30 19:37:46 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-30 19:37:46 +0200
commit7984bff52a9952219a3c15b88ff6514244dd7498 (patch)
treebcf67bde15ab80a95d773d75b6400082ca5e492b /Lib/test/test_bytes.py
parenta1fd5e4bc744bc972691f1d5c23130395e1e306a (diff)
parentd1af5effc214f474bcb1df62eb2089c48f657ee5 (diff)
downloadcpython-git-7984bff52a9952219a3c15b88ff6514244dd7498.tar.gz
Issue #28385: An error message when non-empty format spec is passed to
object.__format__ now contains the name of actual type.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r--Lib/test/test_bytes.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 2224424efb..b396a76a40 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -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)