summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compiler.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_compiler.py')
-rw-r--r--Lib/test/test_compiler.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py
index ab9a660..bbd7511 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)