summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-07-29 18:10:01 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-07-29 18:10:01 (GMT)
commit447d33ead62b6dcd46d475a703f59940eb85428b (patch)
treefbae188f574406c408058b2924d98e764ff062e1 /Lib
parent5de17db361d4cbf194c07b8ee5e037bb3bf3ae13 (diff)
downloadcpython-447d33ead62b6dcd46d475a703f59940eb85428b.zip
cpython-447d33ead62b6dcd46d475a703f59940eb85428b.tar.gz
cpython-447d33ead62b6dcd46d475a703f59940eb85428b.tar.bz2
Implement PEP 3120.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/badsyntax_pep3120.py1
-rw-r--r--Lib/test/test_pep3120.py30
2 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/badsyntax_pep3120.py b/Lib/test/badsyntax_pep3120.py
new file mode 100644
index 0000000..d14b4c9
--- /dev/null
+++ b/Lib/test/badsyntax_pep3120.py
@@ -0,0 +1 @@
+print("böse")
diff --git a/Lib/test/test_pep3120.py b/Lib/test/test_pep3120.py
new file mode 100644
index 0000000..3f567bf
--- /dev/null
+++ b/Lib/test/test_pep3120.py
@@ -0,0 +1,30 @@
+# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.
+
+import unittest
+from test import test_support
+
+class PEP3120Test(unittest.TestCase):
+
+ def test_pep3120(self):
+ self.assertEqual(
+ "Питон".encode("utf-8"),
+ b'\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd'
+ )
+ self.assertEqual(
+ "\П".encode("utf-8"),
+ b'\\\xd0\x9f'
+ )
+
+ def test_badsyntax(self):
+ try:
+ import test.badsyntax_pep3120
+ except SyntaxError as msg:
+ self.assert_(str(msg).find("Non-UTF-8 code starting with") >= 0)
+ else:
+ self.fail("expected exception didn't occur")
+
+def test_main():
+ test_support.run_unittest(PEP3120Test)
+
+if __name__=="__main__":
+ test_main()