Merge branch 'dev' of github.com:davidhalter/jedi into dev

This commit is contained in:
David Halter
2012-11-26 11:42:26 +01:00
2 changed files with 16 additions and 4 deletions

View File

@@ -19,9 +19,11 @@ class BaseOutput(object):
'_io': 'io'
}
_tuple_mapping = {
('argparse', '_ActionsContainer'): 'argparse._ActionsContainer'
}
_tuple_mapping = dict((tuple(k.split('.')), v) for (k, v) in {
'argparse._ActionsContainer': 'argparse.ArgumentParser',
'_sre.SRE_Match': 're.MatchObject',
'_sre.SRE_Pattern': 're.RegexObject',
}.items())
def __init__(self, definition, start_pos):
self.start_pos = start_pos
@@ -97,7 +99,7 @@ class BaseOutput(object):
pass
for key, repl in self._tuple_mapping.items():
if tuple(path[:len(key)]) == key:
path = [repl] + path[len(key)]
path = [repl] + path[len(key):]
return '.'.join(path)

View File

@@ -234,6 +234,16 @@ class TestFeature(Base):
assert self.complete('import os; os.path.join')[0].full_name \
== 'os.path.join'
def test_full_name_tuple_mapping(self):
s = """
import re
any_re = re.compile('.*')
any_re"""
lines = s.splitlines()
defs = self.get_def(s, (len(lines), len(lines[-1])))
self.assertEqual(defs[0].full_name,
're.RegexObject')
class TestSpeed(Base):
def _check_speed(time_per_run, number=4, run_warm=True):