This commit is contained in:
David Halter
2012-09-06 11:23:12 +02:00
parent 61cb267dd5
commit 844e222ed5
6 changed files with 20 additions and 19 deletions

View File

@@ -4,7 +4,7 @@ python versions.
"""
import sys
is_py3k = sys.hexversion >= 0x03000000
is_py3k = sys.hexversion >= 0x03000000
is_py25 = sys.hexversion < 0x02060000
@@ -93,6 +93,7 @@ else:
except AttributeError:
return False
class Python3Method(object):
def __init__(self, func):
self.func = func
@@ -109,6 +110,7 @@ try:
except ImportError:
reduce = reduce
def use_metaclass(meta, *bases):
""" Create a class with a metaclass. """
if not bases:
@@ -120,6 +122,7 @@ try:
except ImportError:
# python 2.5 doesn't have this method
import string
def cleandoc(doc):
"""Clean up indentation from docstrings.
@@ -141,7 +144,8 @@ except ImportError:
if lines:
lines[0] = lines[0].lstrip()
if margin < sys.maxint:
for i in range(1, len(lines)): lines[i] = lines[i][margin:]
for i in range(1, len(lines)):
lines[i] = lines[i][margin:]
# Remove any trailing or leading blank lines.
while lines and not lines[-1]:
lines.pop()

View File

@@ -993,7 +993,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
# class renames
add = [InstanceElement(check_instance, a, True)
if isinstance(a, (Function, parsing.Function))
else a for a in add ]
else a for a in add]
res_new += add
else:
if isinstance(r, parsing.Class):
@@ -1030,8 +1030,6 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
"""
result = []
no_break_scope = False
#if isinstance(scope, InstanceElement) and scope.var == name.parent().parent():
#name = InstanceElement(scope.instance, name)
par = name.parent()
if par.isinstance(parsing.Flow):

View File

@@ -36,7 +36,7 @@ class Completion(object):
append = ''
funcs = (parsing.Function, evaluate.Function)
if settings.add_bracket_after_function \
and isinstance( self._completion_parent, funcs):
and isinstance(self._completion_parent, funcs):
append = '('
if settings.add_dot_after_module:

View File

@@ -92,7 +92,8 @@ class ExecutionRecursionDecorator(object):
self.reset()
def __call__(self, execution, evaluate_generator=False):
#print execution, self.recursion_level, self.execution_count, len(self.execution_funcs), a
debug.dbg('Execution recursions: ', execution, self.recursion_level,
self.execution_count, len(self.execution_funcs))
if self.check_recursion(execution, evaluate_generator):
result = []
else:

View File

@@ -30,7 +30,6 @@ class TestRegression(unittest.TestCase):
"A.different_line"
)
in_name = 2, 9
under_score = 2, 8
cls = 2, 7
@@ -55,29 +54,29 @@ class TestRegression(unittest.TestCase):
self.assertRaises(functions.NotFoundError, get_def, cls)
def test_keyword_doc(self):
r = list(self.get_def("or", (1,1)))
r = list(self.get_def("or", (1, 1)))
assert len(r) == 1
if not is_py25:
assert len(r[0].doc) > 100
r = list(self.get_def("asfdasfd", (1,1)))
r = list(self.get_def("asfdasfd", (1, 1)))
assert len(r) == 0
def test_operator_doc(self):
r = list(self.get_def("a == b", (1,3)))
r = list(self.get_def("a == b", (1, 3)))
assert len(r) == 1
if not is_py25:
assert len(r[0].doc) > 100
def test_get_definition_at_zero(self):
assert self.get_def("a", (1,1)) == set()
s = self.get_def("str", (1,1))
assert self.get_def("a", (1, 1)) == set()
s = self.get_def("str", (1, 1))
assert len(s) == 1
assert list(s)[0].description == 'class str'
assert self.get_def("", (1,0)) == set()
assert self.get_def("", (1, 0)) == set()
def test_complete_at_zero(self):
s = self.complete("str", (1,3))
s = self.complete("str", (1, 3))
assert len(s) == 1
assert list(s)[0].word == 'str'

View File

@@ -7,7 +7,7 @@ import traceback
os.chdir(os.path.dirname(os.path.abspath(__file__)) + '/..')
sys.path.append('.')
from _compatibility import unicode, BytesIO, reduce, literal_eval
from _compatibility import unicode, BytesIO, reduce, literal_eval, is_py25
import functions
import debug
@@ -185,8 +185,7 @@ def test_dir(completion_test_dir, thirdparty=False):
if f_name.endswith(".py") and (not test_files or files_to_execute):
# for python2.5 certain tests are not being done, because it
# only has these features partially.
if sys.hexversion < 0x02060000 \
and f_name in ['generators.py', 'types.py']:
if is_py25 and f_name in ['generators.py', 'types.py']:
continue
if thirdparty: