mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
Merge with master
The deprecation of Python2.6 and the insertion of environments made it quite difficult to merge.
This commit is contained in:
@@ -103,8 +103,8 @@ def test_completion_on_complex_literals(Script):
|
||||
_check_number(Script, '4.0j.', 'complex')
|
||||
# No dot no completion - I thought, but 4j is actually a literall after
|
||||
# which a keyword like or is allowed. Good times, haha!
|
||||
assert (set([c.name for c in Script('4j').completions()]) ==
|
||||
set(['if', 'and', 'in', 'is', 'not', 'or']))
|
||||
assert ({c.name for c in Script('4j').completions()} ==
|
||||
{'if', 'and', 'in', 'is', 'not', 'or'})
|
||||
|
||||
|
||||
def test_goto_assignments_on_non_name(Script, environment):
|
||||
@@ -152,7 +152,7 @@ def test_goto_definition_not_multiple(Script):
|
||||
|
||||
def test_usage_description(Script):
|
||||
descs = [u.description for u in Script("foo = ''; foo").usages()]
|
||||
assert set(descs) == set(["foo = ''", 'foo'])
|
||||
assert set(descs) == {"foo = ''", 'foo'}
|
||||
|
||||
|
||||
def test_get_line_code(Script):
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_follow_import_incomplete(Script):
|
||||
|
||||
# incomplete `from * import` part
|
||||
datetime = check_follow_definition_types(Script, "from datetime import datetim")
|
||||
assert set(datetime) == set(['class', 'instance']) # py33: builtin and pure py version
|
||||
assert set(datetime) == {'class', 'instance'} # py33: builtin and pure py version
|
||||
|
||||
# os.path check
|
||||
ospath = check_follow_definition_types(Script, "from os.path import abspat")
|
||||
|
||||
@@ -68,25 +68,25 @@ def test_basedefinition_type(Script, environment):
|
||||
|
||||
def test_basedefinition_type_import(Script):
|
||||
def get_types(source, **kwargs):
|
||||
return set([t.type for t in Script(source, **kwargs).completions()])
|
||||
return {t.type for t in Script(source, **kwargs).completions()}
|
||||
|
||||
# import one level
|
||||
assert get_types('import t') == set(['module'])
|
||||
assert get_types('import ') == set(['module'])
|
||||
assert get_types('import datetime; datetime') == set(['module'])
|
||||
assert get_types('import t') == {'module'}
|
||||
assert get_types('import ') == {'module'}
|
||||
assert get_types('import datetime; datetime') == {'module'}
|
||||
|
||||
# from
|
||||
assert get_types('from datetime import timedelta') == set(['class'])
|
||||
assert get_types('from datetime import timedelta; timedelta') == set(['class'])
|
||||
assert get_types('from json import tool') == set(['module'])
|
||||
assert get_types('from json import tool; tool') == set(['module'])
|
||||
assert get_types('from datetime import timedelta') == {'class'}
|
||||
assert get_types('from datetime import timedelta; timedelta') == {'class'}
|
||||
assert get_types('from json import tool') == {'module'}
|
||||
assert get_types('from json import tool; tool') == {'module'}
|
||||
|
||||
# import two levels
|
||||
assert get_types('import json.tool; json') == set(['module'])
|
||||
assert get_types('import json.tool; json.tool') == set(['module'])
|
||||
assert get_types('import json.tool; json.tool.main') == set(['function'])
|
||||
assert get_types('import json.tool') == set(['module'])
|
||||
assert get_types('import json.tool', column=9) == set(['module'])
|
||||
assert get_types('import json.tool; json') == {'module'}
|
||||
assert get_types('import json.tool; json.tool') == {'module'}
|
||||
assert get_types('import json.tool; json.tool.main') == {'function'}
|
||||
assert get_types('import json.tool') == {'module'}
|
||||
assert get_types('import json.tool', column=9) == {'module'}
|
||||
|
||||
|
||||
def test_function_call_signature_in_doc(Script):
|
||||
|
||||
@@ -16,8 +16,8 @@ else:
|
||||
exec source in global_map """, 'blub', 'exec'))
|
||||
|
||||
|
||||
class _GlobalNameSpace():
|
||||
class SideEffectContainer():
|
||||
class _GlobalNameSpace:
|
||||
class SideEffectContainer:
|
||||
pass
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ def test_numpy_like_non_zero():
|
||||
|
||||
|
||||
def test_nested_resolve():
|
||||
class XX():
|
||||
class XX:
|
||||
def x():
|
||||
pass
|
||||
|
||||
@@ -168,7 +168,7 @@ def test_list():
|
||||
|
||||
|
||||
def test_slice():
|
||||
class Foo1():
|
||||
class Foo1:
|
||||
bar = []
|
||||
baz = 'xbarx'
|
||||
_assert_interpreter_complete('getattr(Foo1, baz[1:-1]).append',
|
||||
@@ -177,7 +177,7 @@ def test_slice():
|
||||
|
||||
|
||||
def test_getitem_side_effects():
|
||||
class Foo2():
|
||||
class Foo2:
|
||||
def __getitem__(self, index):
|
||||
# Possible side effects here, should therefore not call this.
|
||||
if True:
|
||||
@@ -190,7 +190,7 @@ def test_getitem_side_effects():
|
||||
|
||||
def test_property_error_oldstyle():
|
||||
lst = []
|
||||
class Foo3():
|
||||
class Foo3:
|
||||
@property
|
||||
def bar(self):
|
||||
lst.append(1)
|
||||
@@ -261,7 +261,7 @@ def test_completion_param_annotations():
|
||||
a, b, c = c.params
|
||||
assert a._goto_definitions() == []
|
||||
assert [d.name for d in b._goto_definitions()] == ['str']
|
||||
assert set([d.name for d in c._goto_definitions()]) == set(['int', 'float'])
|
||||
assert {d.name for d in c._goto_definitions()} == {'int', 'float'}
|
||||
|
||||
|
||||
def test_more_complex_instances():
|
||||
@@ -269,7 +269,7 @@ def test_more_complex_instances():
|
||||
def foo(self, other):
|
||||
return self
|
||||
|
||||
class Base():
|
||||
class Base:
|
||||
def wow(self):
|
||||
return Something()
|
||||
|
||||
|
||||
@@ -63,3 +63,12 @@ def test_complete_at_zero(Script):
|
||||
|
||||
s = Script("", 1, 0).completions()
|
||||
assert len(s) > 0
|
||||
|
||||
|
||||
def test_wrong_encoding(Script, cwd_tmpdir):
|
||||
x = cwd_tmpdir.join('x.py')
|
||||
# Use both latin-1 and utf-8 (a really broken file).
|
||||
x.write_binary(u'foobar = 1\nä'.encode('latin-1') + 'ä'.encode())
|
||||
|
||||
c, = Script('import x; x.foo', sys_path=['.']).completions()
|
||||
assert c.name == 'foobar'
|
||||
|
||||
Reference in New Issue
Block a user