mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-20 10:52:50 +08:00
Python 2.7 compatibility.
This commit is contained in:
@@ -27,8 +27,8 @@ class MixinTestFullName(object):
|
||||
def check(self, source, desired):
|
||||
script = jedi.Script(textwrap.dedent(source))
|
||||
definitions = getattr(script, type(self).operation)()
|
||||
assert len(definitions) == 1
|
||||
self.assertEqual(definitions[0].full_name, desired)
|
||||
for d in definitions:
|
||||
self.assertEqual(d.full_name, desired)
|
||||
|
||||
def test_os_path_join(self):
|
||||
self.check('import os; os.path.join', 'os.path.join')
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""
|
||||
Test of keywords and ``jedi.keywords``
|
||||
"""
|
||||
import jedi
|
||||
from jedi import Script, common
|
||||
from jedi._compatibility import is_py3
|
||||
from jedi import Script
|
||||
|
||||
|
||||
def test_goto_assignments_keyword():
|
||||
@@ -17,7 +17,10 @@ def test_goto_assignments_keyword():
|
||||
def test_keyword():
|
||||
""" github jedi-vim issue #44 """
|
||||
defs = Script("print").goto_definitions()
|
||||
assert [d.doc for d in defs]
|
||||
if is_py3:
|
||||
assert [d.doc for d in defs]
|
||||
else:
|
||||
assert defs == []
|
||||
|
||||
assert Script("import").goto_assignments() == []
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from jedi._compatibility import u
|
||||
from jedi.parser import Parser, load_grammar
|
||||
|
||||
|
||||
@@ -6,7 +7,7 @@ def test_basic_parsing():
|
||||
"""Generates the AST object and then regenerates the code."""
|
||||
assert Parser(load_grammar(), string).module.get_code() == string
|
||||
|
||||
compare('\na #pass\n')
|
||||
compare('wblabla* 1\t\n')
|
||||
compare('def x(a, b:3): pass\n')
|
||||
compare('assert foo\n')
|
||||
compare(u('\na #pass\n'))
|
||||
compare(u('wblabla* 1\t\n'))
|
||||
compare(u('def x(a, b:3): pass\n'))
|
||||
compare(u('assert foo\n'))
|
||||
|
||||
@@ -27,7 +27,7 @@ asdfasdf""" + "h"
|
||||
|
||||
def test_simple_no_whitespace(self):
|
||||
# Test a simple one line string, no preceding whitespace
|
||||
simple_docstring = u'"""simple one line docstring"""'
|
||||
simple_docstring = u('"""simple one line docstring"""')
|
||||
simple_docstring_io = StringIO(simple_docstring)
|
||||
tokens = parser.tokenize.generate_tokens(simple_docstring_io.readline)
|
||||
token_list = list(tokens)
|
||||
@@ -37,7 +37,7 @@ asdfasdf""" + "h"
|
||||
|
||||
def test_simple_with_whitespace(self):
|
||||
# Test a simple one line string with preceding whitespace and newline
|
||||
simple_docstring = ' """simple one line docstring""" \r\n'
|
||||
simple_docstring = u(' """simple one line docstring""" \r\n')
|
||||
simple_docstring_io = StringIO(simple_docstring)
|
||||
tokens = parser.tokenize.generate_tokens(simple_docstring_io.readline)
|
||||
token_list = list(tokens)
|
||||
@@ -51,11 +51,11 @@ asdfasdf""" + "h"
|
||||
|
||||
def test_function_whitespace(self):
|
||||
# Test function definition whitespace identification
|
||||
fundef = '''def test_whitespace(*args, **kwargs):
|
||||
fundef = u('''def test_whitespace(*args, **kwargs):
|
||||
x = 1
|
||||
if x > 0:
|
||||
print(True)
|
||||
'''
|
||||
''')
|
||||
fundef_io = StringIO(fundef)
|
||||
tokens = parser.tokenize.generate_tokens(fundef_io.readline)
|
||||
token_list = list(tokens)
|
||||
|
||||
Reference in New Issue
Block a user