mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-10 14:02:27 +08:00
changed _compatibility.utf8 -> 'u' and removed a lot of the issues with the now enforced unicode source input of the parser
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
All character set and unicode related tests.
|
||||
"""
|
||||
from jedi import Script
|
||||
from jedi._compatibility import utf8, unicode
|
||||
from jedi._compatibility import u, unicode
|
||||
|
||||
|
||||
def test_unicode_script():
|
||||
@@ -13,12 +13,12 @@ def test_unicode_script():
|
||||
assert len(completions)
|
||||
assert type(completions[0].description) is unicode
|
||||
|
||||
s = utf8("author='öä'; author")
|
||||
s = u("author='öä'; author")
|
||||
completions = Script(s).completions()
|
||||
x = completions[0].description
|
||||
assert type(x) is unicode
|
||||
|
||||
s = utf8("#-*- coding: iso-8859-1 -*-\nauthor='öä'; author")
|
||||
s = u("#-*- coding: iso-8859-1 -*-\nauthor='öä'; author")
|
||||
s = s.encode('latin-1')
|
||||
completions = Script(s).completions()
|
||||
assert type(completions[0].description) is unicode
|
||||
@@ -26,12 +26,12 @@ def test_unicode_script():
|
||||
|
||||
def test_unicode_attribute():
|
||||
""" github jedi-vim issue #94 """
|
||||
s1 = utf8('#-*- coding: utf-8 -*-\nclass Person():\n'
|
||||
' name = "e"\n\nPerson().name.')
|
||||
s1 = u('#-*- 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.')
|
||||
s2 = u('#-*- coding: utf-8 -*-\nclass Person():\n'
|
||||
' name = "é"\n\nPerson().name.')
|
||||
completions2 = Script(s2).completions()
|
||||
assert 'strip' in [c.name for c in completions2]
|
||||
|
||||
@@ -39,9 +39,9 @@ def test_unicode_attribute():
|
||||
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')
|
||||
code = u("import datetime; datetime.d")
|
||||
comment = u("# multi-byte comment あいうえおä")
|
||||
s = (u('%s\n%s') % (code, comment)).encode('utf-8')
|
||||
except NameError:
|
||||
pass # python 3 has no unicode method
|
||||
else:
|
||||
|
||||
@@ -3,6 +3,7 @@ Tests ``from __future__ import absolute_import`` (only important for
|
||||
Python 2.X)
|
||||
"""
|
||||
import jedi
|
||||
from jedi._compatibility import u
|
||||
from jedi.parser import Parser
|
||||
from .. import helpers
|
||||
|
||||
@@ -11,7 +12,7 @@ def test_explicit_absolute_imports():
|
||||
"""
|
||||
Detect modules with ``from __future__ import absolute_import``.
|
||||
"""
|
||||
parser = Parser("from __future__ import absolute_import", "test.py")
|
||||
parser = Parser(u("from __future__ import absolute_import"), "test.py")
|
||||
assert parser.module.has_explicit_absolute_import
|
||||
|
||||
|
||||
@@ -19,7 +20,7 @@ def test_no_explicit_absolute_imports():
|
||||
"""
|
||||
Detect modules without ``from __future__ import absolute_import``.
|
||||
"""
|
||||
parser = Parser("1", "test.py")
|
||||
parser = Parser(u("1"), "test.py")
|
||||
assert not parser.module.has_explicit_absolute_import
|
||||
|
||||
|
||||
@@ -28,7 +29,7 @@ def test_dont_break_imports_without_namespaces():
|
||||
The code checking for ``from __future__ import absolute_import`` shouldn't
|
||||
assume that all imports have non-``None`` namespaces.
|
||||
"""
|
||||
src = "from __future__ import absolute_import\nimport xyzzy"
|
||||
src = u("from __future__ import absolute_import\nimport xyzzy")
|
||||
parser = Parser(src, "test.py")
|
||||
assert parser.module.has_explicit_absolute_import
|
||||
|
||||
|
||||
Reference in New Issue
Block a user