Add a test for multi-byte string source

This commit is contained in:
Takafumi Arakaki
2012-11-10 19:55:56 +01:00
parent 8dd9952288
commit 8b31117faf
2 changed files with 22 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import unittest
@@ -10,7 +11,7 @@ sys.path.append(abspath(dirname(abspath(__file__)) + '/../jedi'))
os.chdir(os.path.dirname(os.path.abspath(__file__)) + '/../jedi')
sys.path.append('.')
from _compatibility import is_py25
from _compatibility import is_py25, utf8
import api
#api.set_debug_function(api.debug.print_to_stdout)
@@ -206,6 +207,17 @@ class TestRegression(Base):
else:
assert len(self.complete(s))
def test_multibyte_script(self):
""" `jedi.Script` must accept multi-byte string source. """
try:
code = unicode("import datetime; datetime.d")
comment = utf8("# multi-byte comment あいうえお")
s = (unicode('%s\n%s') % (code, comment)).encode('utf-8')
except NameError:
pass # python 3 has no unicode method
else:
assert len(self.complete(s, (1, len(code))))
def test_os_nowait(self):
""" github issue #45 """
s = self.complete("import os; os.P_")