diff options
author | Thomas Wouters <thomas@python.org> | 2007-02-23 19:56:57 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2007-02-23 19:56:57 (GMT) |
commit | 00e41defe8801ef37548fb60abacb3be13156d2a (patch) | |
tree | 863d072e568fee2b8f4959016b5954de457c7f4c /Lib/test/test_bytes.py | |
parent | cf297e46b85257396560774e5492e9d71a40f32e (diff) | |
download | cpython-00e41defe8801ef37548fb60abacb3be13156d2a.zip cpython-00e41defe8801ef37548fb60abacb3be13156d2a.tar.gz cpython-00e41defe8801ef37548fb60abacb3be13156d2a.tar.bz2 |
Bytes literal.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r-- | Lib/test/test_bytes.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 997122b..4dee01b 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -403,7 +403,19 @@ class BytesTest(unittest.TestCase): self.assertEqual(bytes.join(tuple(lst)), bytes("abc")) self.assertEqual(bytes.join(iter(lst)), bytes("abc")) # XXX more... - + + def test_literal(self): + tests = [ + (b"Wonderful spam", u"Wonderful spam"), + (br"Wonderful spam too", u"Wonderful spam too"), + (b"\xaa\x00\000\200", u"\xaa\x00\000\200"), + (br"\xaa\x00\000\200", ur"\xaa\x00\000\200"), + ] + for b, s in tests: + self.assertEqual(b, bytes(s, 'latin-1')) + for c in range(128, 256): + self.assertRaises(SyntaxError, eval, + 'b"%s"' % chr(c)) # Optimizations: # __iter__? (optimization) |