[pypy-commit] pypy stdlib-2.7.9: add failing test for coding spec
bdkearns
noreply at buildbot.pypy.org
Thu Dec 18 03:00:24 CET 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.9
Changeset: r75007:3ad403fdd1ae
Date: 2014-12-17 20:46 -0500
http://bitbucket.org/pypy/pypy/changeset/3ad403fdd1ae/
Log: add failing test for coding spec
diff --git a/pypy/interpreter/test/test_compiler.py b/pypy/interpreter/test/test_compiler.py
--- a/pypy/interpreter/test/test_compiler.py
+++ b/pypy/interpreter/test/test_compiler.py
@@ -990,8 +990,6 @@
else:
raise Exception("DID NOT RAISE")
-
-
def test_bad_oudent(self):
source = """if 1:
x
@@ -1005,7 +1003,6 @@
else:
raise Exception("DID NOT RAISE")
-
def test_repr_vs_str(self):
source1 = "x = (\n"
source2 = "x = (\n\n"
@@ -1026,3 +1023,21 @@
err3 = eval(repr(err1))
assert str(err3) == str(err1)
assert repr(err3) == repr(err1)
+
+ def test_encoding(self):
+ code = b'# -*- coding: badencoding -*-\npass\n'
+ raises(SyntaxError, compile, code, 'tmp', 'exec')
+ code = u"# -*- coding: utf-8 -*-\npass\n"
+ raises(SyntaxError, compile, code, 'tmp', 'exec')
+ code = 'u"\xc2\xa4"\n'
+ assert eval(code) == u'\xc2\xa4'
+ code = u'u"\xc2\xa4"\n'
+ assert eval(code) == u'\xc2\xa4'
+ code = '# -*- coding: latin1 -*-\nu"\xc2\xa4"\n'
+ assert eval(code) == u'\xc2\xa4'
+ code = '# -*- coding: utf-8 -*-\nu"\xc2\xa4"\n'
+ assert eval(code) == u'\xa4'
+ code = '# -*- coding: iso8859-15 -*-\nu"\xc2\xa4"\n'
+ assert eval(code) == u'\xc2\u20ac'
+ code = 'u"""\\\n# -*- coding: utf-8 -*-\n\xc2\xa4"""\n'
+ assert eval(code) == u'# -*- coding: utf-8 -*-\n\xc2\xa4'
More information about the pypy-commit
mailing list