mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
moved more methods out of regression tests, created test_unicode.py, #181
This commit is contained in:
@@ -118,45 +118,6 @@ class TestRegression(TestBase):
|
||||
assert len(result) == 1
|
||||
assert result[0].description == 'class int'
|
||||
|
||||
def test_unicode_script(self):
|
||||
""" normally no unicode objects are being used. (<=2.7) """
|
||||
s = unicode("import datetime; datetime.timedelta")
|
||||
completions = self.completions(s)
|
||||
assert len(completions)
|
||||
assert type(completions[0].description) is unicode
|
||||
|
||||
s = utf8("author='öä'; author")
|
||||
completions = self.completions(s)
|
||||
x = completions[0].description
|
||||
assert type(x) is unicode
|
||||
|
||||
s = utf8("#-*- coding: iso-8859-1 -*-\nauthor='öä'; author")
|
||||
s = s.encode('latin-1')
|
||||
completions = self.completions(s)
|
||||
assert type(completions[0].description) is unicode
|
||||
|
||||
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.completions(s, (1, len(code))))
|
||||
|
||||
def test_unicode_attribute(self):
|
||||
""" github jedi-vim issue #94 """
|
||||
s1 = utf8('#-*- coding: utf-8 -*-\nclass Person():\n'
|
||||
' name = "e"\n\nPerson().name.')
|
||||
completions1 = self.completions(s1)
|
||||
assert 'strip' in [c.name for c in completions1]
|
||||
s2 = utf8('#-*- coding: utf-8 -*-\nclass Person():\n'
|
||||
' name = "é"\n\nPerson().name.')
|
||||
completions2 = self.completions(s2)
|
||||
assert 'strip' in [c.name for c in completions2]
|
||||
|
||||
def test_os_nowait(self):
|
||||
""" github issue #45 """
|
||||
s = self.completions("import os; os.P_")
|
||||
|
||||
45
test/test_unicode.py
Normal file
45
test/test_unicode.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""
|
||||
All character set and unicode related tests.
|
||||
"""
|
||||
from jedi import Script
|
||||
from jedi._compatibility import utf8, unicode
|
||||
|
||||
def test_unicode_script():
|
||||
""" normally no unicode objects are being used. (<=2.7) """
|
||||
s = unicode("import datetime; datetime.timedelta")
|
||||
completions = Script(s).completions()
|
||||
assert len(completions)
|
||||
assert type(completions[0].description) is unicode
|
||||
|
||||
s = utf8("author='öä'; author")
|
||||
completions = Script(s).completions()
|
||||
x = completions[0].description
|
||||
assert type(x) is unicode
|
||||
|
||||
s = utf8("#-*- coding: iso-8859-1 -*-\nauthor='öä'; author")
|
||||
s = s.encode('latin-1')
|
||||
completions = Script(s).completions()
|
||||
assert type(completions[0].description) is unicode
|
||||
|
||||
def test_unicode_attribute():
|
||||
""" github jedi-vim issue #94 """
|
||||
s1 = utf8('#-*- coding: utf-8 -*-\nclass Person():\n'
|
||||
' name = "e"\n\nPerson().name.')
|
||||
completions1 = Script(s1).completions()
|
||||
assert 'strip' in [c.name for c in completions1]
|
||||
s2 = utf8('#-*- coding: utf-8 -*-\nclass Person():\n'
|
||||
' name = "é"\n\nPerson().name.')
|
||||
completions2 = Script(s2).completions()
|
||||
assert 'strip' in [c.name for c in completions2]
|
||||
|
||||
def test_multibyte_script():
|
||||
""" `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(Script(s, 1, len(code)).completions())
|
||||
|
||||
Reference in New Issue
Block a user