diff options
author | Thomas Wouters <thomas@python.org> | 2007-02-23 19:56:57 +0000 |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2007-02-23 19:56:57 +0000 |
commit | 00e41defe8801ef37548fb60abacb3be13156d2a (patch) | |
tree | 863d072e568fee2b8f4959016b5954de457c7f4c /Lib/test/test_compiler.py | |
parent | cf297e46b85257396560774e5492e9d71a40f32e (diff) | |
download | cpython-git-00e41defe8801ef37548fb60abacb3be13156d2a.tar.gz |
Bytes literal.
Diffstat (limited to 'Lib/test/test_compiler.py')
-rw-r--r-- | Lib/test/test_compiler.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py index ab9a66045a..bbd7511900 100644 --- a/Lib/test/test_compiler.py +++ b/Lib/test/test_compiler.py @@ -187,6 +187,30 @@ class CompilerTest(unittest.TestCase): exec(c, dct) self.assertEquals(dct.get('result'), 1) + def testBytesLiteral(self): + c = compiler.compile("b'foo'", '<string>', 'eval') + b = eval(c) + + c = compiler.compile('def f(b=b"foo"):\n' + ' b[0] += 1\n' + ' return b\n' + 'f(); f(); result = f()\n', + '<string>', + 'exec') + dct = {} + exec(c, dct) + self.assertEquals(dct.get('result'), b"ioo") + + c = compiler.compile('def f():\n' + ' b = b"foo"\n' + ' b[0] += 1\n' + ' return b\n' + 'f(); f(); result = f()\n', + '<string>', + 'exec') + dct = {} + exec(c, dct) + self.assertEquals(dct.get('result'), b"goo") NOLINENO = (compiler.ast.Module, compiler.ast.Stmt, compiler.ast.Discard) |