mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
fix unicode issues with python2.7
This commit is contained in:
@@ -48,7 +48,6 @@ class UserContext(object):
|
|||||||
while True:
|
while True:
|
||||||
self._line_temp -= 1
|
self._line_temp -= 1
|
||||||
last_line = self.get_line(self._line_temp)
|
last_line = self.get_line(self._line_temp)
|
||||||
#print self._line_temp, repr(last_line)
|
|
||||||
if last_line and last_line[-1] == '\\':
|
if last_line and last_line[-1] == '\\':
|
||||||
line = last_line[:-1] + ' ' + line
|
line = last_line[:-1] + ' ' + line
|
||||||
self._line_length = len(last_line)
|
self._line_length = len(last_line)
|
||||||
@@ -64,7 +63,7 @@ class UserContext(object):
|
|||||||
close_brackets = [')', ']', '}']
|
close_brackets = [')', ']', '}']
|
||||||
|
|
||||||
gen = tokenize.generate_tokens(fetch_line)
|
gen = tokenize.generate_tokens(fetch_line)
|
||||||
string = ''
|
string = u('')
|
||||||
level = 0
|
level = 0
|
||||||
force_point = False
|
force_point = False
|
||||||
last_type = None
|
last_type = None
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ def process_memory():
|
|||||||
uri = 'http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/src/gtk/_core.py?revision=74740&content-type=text%2Fplain&view=co'
|
uri = 'http://svn.wxwidgets.org/viewvc/wx/wxPython/trunk/src/gtk/_core.py?revision=74740&content-type=text%2Fplain&view=co'
|
||||||
|
|
||||||
wx_core = urllib2.urlopen(uri).read()
|
wx_core = urllib2.urlopen(uri).read()
|
||||||
wx_core = wx_core[:1]
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
@@ -45,7 +44,6 @@ def run():
|
|||||||
print('Process Memory before: %skB' % process_memory())
|
print('Process Memory before: %skB' % process_memory())
|
||||||
# After this the module should be cached.
|
# After this the module should be cached.
|
||||||
# Need to invent a path so that it's really cached.
|
# Need to invent a path so that it's really cached.
|
||||||
print type(wx_core), wx_core
|
|
||||||
jedi.Script(wx_core, path='foobar.py').completions()
|
jedi.Script(wx_core, path='foobar.py').completions()
|
||||||
|
|
||||||
gc.collect() # make sure that it's all fair and the gc did its job.
|
gc.collect() # make sure that it's all fair and the gc did its job.
|
||||||
|
|||||||
@@ -46,3 +46,21 @@ def test_multibyte_script():
|
|||||||
pass # python 3 has no unicode method
|
pass # python 3 has no unicode method
|
||||||
else:
|
else:
|
||||||
assert len(Script(s, 1, len(code)).completions())
|
assert len(Script(s, 1, len(code)).completions())
|
||||||
|
|
||||||
|
|
||||||
|
def test_goto_definition_at_zero():
|
||||||
|
"""At zero usually sometimes raises unicode issues."""
|
||||||
|
assert Script("a", 1, 1).goto_definitions() == []
|
||||||
|
s = Script("str", 1, 1).goto_definitions()
|
||||||
|
assert len(s) == 1
|
||||||
|
assert list(s)[0].description == 'class str'
|
||||||
|
assert Script("", 1, 0).goto_definitions() == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_complete_at_zero():
|
||||||
|
s = Script("str", 1, 3).completions()
|
||||||
|
assert len(s) == 1
|
||||||
|
assert list(s)[0].name == 'str'
|
||||||
|
|
||||||
|
s = Script("", 1, 0).completions()
|
||||||
|
assert len(s) > 0
|
||||||
|
|||||||
@@ -56,21 +56,6 @@ class TestRegression(TestCase):
|
|||||||
|
|
||||||
self.assertRaises(jedi.NotFoundError, get_def, cls)
|
self.assertRaises(jedi.NotFoundError, get_def, cls)
|
||||||
|
|
||||||
def test_goto_definition_at_zero(self):
|
|
||||||
assert Script("a", 1, 1).goto_definitions() == []
|
|
||||||
s = Script("str", 1, 1).goto_definitions()
|
|
||||||
assert len(s) == 1
|
|
||||||
assert list(s)[0].description == 'class str'
|
|
||||||
assert Script("", 1, 0).goto_definitions() == []
|
|
||||||
|
|
||||||
def test_complete_at_zero(self):
|
|
||||||
s = Script("str", 1, 3).completions()
|
|
||||||
assert len(s) == 1
|
|
||||||
assert list(s)[0].name == 'str'
|
|
||||||
|
|
||||||
s = Script("", 1, 0).completions()
|
|
||||||
assert len(s) > 0
|
|
||||||
|
|
||||||
@pytest.mark.skip('Skip for now, test case is not really supported.')
|
@pytest.mark.skip('Skip for now, test case is not really supported.')
|
||||||
@cwd_at('jedi')
|
@cwd_at('jedi')
|
||||||
def test_add_dynamic_mods(self):
|
def test_add_dynamic_mods(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user