コード例 #1
0
ファイル: run.py プロジェクト: dbrgn/jedi
    def get_defs(correct, correct_start, path):
        def defs(line_nr, indent):
            script = api.Script(source, line_nr, indent, path)
            return set(script.get_definition())

        should_be = set()
        number = 0
        for index in re.finditer('(?: +|$)', correct):
            if correct == ' ':
                continue
            # -1 for the comment, +3 because of the comment start `#? `
            start = index.start()
            if print_debug:
                api.set_debug_function(None)
            number += 1
            try:
                should_be |= defs(line_nr - 1, start + correct_start)
            except Exception:
                print('could not resolve %s indent %s' % (line_nr - 1, start))
                raise
            if print_debug:
                api.set_debug_function(debug.print_to_stdout)
        # because the objects have different ids, `repr` it, then compare it.
        should_str = set(r.desc_with_module for r in should_be)
        if len(should_str) < number:
            raise Exception('Solution @%s not right, too few test results: %s'
                                                % (line_nr - 1, should_str))
        return should_str
コード例 #2
0
    def get_defs(correct, correct_start, path):
        def defs(line_nr, indent):
            script = api.Script(source, line_nr, indent, path)
            return set(script.get_definition())

        should_be = set()
        number = 0
        for index in re.finditer('(?: +|$)', correct):
            if correct == ' ':
                continue
            # -1 for the comment, +3 because of the comment start `#? `
            start = index.start()
            if print_debug:
                api.set_debug_function(None)
            number += 1
            try:
                should_be |= defs(line_nr - 1, start + correct_start)
            except Exception:
                raise Exception('could not resolve %s indent %s'
                                                    % (line_nr - 1, start))
            if print_debug:
                api.set_debug_function(debug.print_to_stdout)
        # because the objects have different ids, `repr` it, then compare it.
        should_str = set(r.desc_with_module for r in should_be)
        if len(should_str) < number:
            raise Exception('Solution @%s not right, too few test results: %s'
                                                % (line_nr - 1, should_str))
        return should_str
コード例 #3
0
ファイル: run.py プロジェクト: dbrgn/jedi
try:
    i = args.index('--thirdparty')
    thirdparty = True
    args = args[:i] + args[i + 1:]
except ValueError:
    thirdparty = False

print_debug = False
try:
    i = args.index('--debug')
    args = args[:i] + args[i + 1:]
except ValueError:
    pass
else:
    print_debug = True
    api.set_debug_function(debug.print_to_stdout)

# get test list, that should be executed
test_files = {}
last = None
for arg in args:
    if arg.isdigit():
        if last is None:
            continue
        test_files[last].append(int(arg))
    else:
        test_files[arg] = []
        last = arg

# completion tests:
completion_test_dir = '../test/completion'
コード例 #4
0
try:
    i = args.index('--thirdparty')
    thirdparty = True
    args = args[:i] + args[i + 1:]
except ValueError:
    thirdparty = False

print_debug = False
try:
    i = args.index('--debug')
    args = args[:i] + args[i + 1:]
except ValueError:
    pass
else:
    print_debug = True
    api.set_debug_function(debug.print_to_stdout)

# get test list, that should be executed
test_files = {}
last = None
for arg in args:
    if arg.isdigit():
        if last is None:
            continue
        test_files[last].append(int(arg))
    else:
        test_files[arg] = []
        last = arg

# completion tests:
completion_test_dir = '../test/completion'