mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Merge pull request #2724 from fanninpm/test-utf8source
Add test_utf8source from CPython 3.8
This commit is contained in:
47
Lib/test/test_utf8source.py
Normal file
47
Lib/test/test_utf8source.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.
|
||||
|
||||
import unittest
|
||||
|
||||
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'
|
||||
)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure # "badsyntax_pep3120.py" may make the WASM CI fail
|
||||
def test_badsyntax(self):
|
||||
try:
|
||||
import test.badsyntax_pep3120
|
||||
except SyntaxError as msg:
|
||||
msg = str(msg).lower()
|
||||
self.assertTrue('utf-8' in msg)
|
||||
else:
|
||||
self.fail("expected exception didn't occur")
|
||||
|
||||
|
||||
class BuiltinCompileTests(unittest.TestCase):
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
# Issue 3574.
|
||||
def test_latin1(self):
|
||||
# Allow compile() to read Latin-1 source.
|
||||
source_code = '# coding: Latin-1\nu = "Ç"\n'.encode("Latin-1")
|
||||
try:
|
||||
code = compile(source_code, '<dummy>', 'exec')
|
||||
except SyntaxError:
|
||||
self.fail("compile() cannot handle Latin-1 source")
|
||||
ns = {}
|
||||
exec(code, ns)
|
||||
self.assertEqual('Ç', ns['u'])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user