예제 #1
0
def test_codeanalysis():
    """Test codeanalysis with pyflakes and pep8."""
    code = open(TEST_FILE).read()
    check_results = check_with_pyflakes(code, TEST_FILE) + \
                    check_with_pep8(code, TEST_FILE) + find_tasks(code)

    assert 85 <= len(check_results) <= 99
예제 #2
0
def test_codeanalysis():
    """Test codeanalysis with pyflakes and pep8."""
    code = open(TEST_FILE).read()
    check_results = check_with_pyflakes(code, TEST_FILE) + \
                    check_with_pep8(code, TEST_FILE) + find_tasks(code)

    assert 85 <= len(check_results) <= 99
예제 #3
0
def test_codeanalysis():
    """Test codeanalysis with pyflakes and pep8."""
    code = open(TEST_FILE).read()
    check_results = check_with_pyflakes(code, TEST_FILE) + \
                    check_with_pep8(code, TEST_FILE) + find_tasks(code)
    if PY2:
        num_results = 89
    else:
        num_results = 90
    assert len(check_results) == num_results
예제 #4
0
def test_codeanalysis_latin():
    """Test codeanalysis with pyflakes and pep8."""
    code = io.open(TEST_FILE_LATIN, encoding="iso-8859-1").read()
    check_results = (check_with_pyflakes(code, TEST_FILE_LATIN) +
                     check_with_pep8(code, TEST_FILE_LATIN) + find_tasks(code))
    if PY2:
        num_results = 1
    else:
        num_results = 2
    assert len(check_results) == num_results
예제 #5
0
def test_codeanalysis():
    """Test codeanalysis with pyflakes and pep8."""
    code = open(TEST_FILE).read()
    check_results = check_with_pyflakes(code, TEST_FILE) + \
                    check_with_pep8(code, TEST_FILE) + find_tasks(code)
    if PY2:
        num_results = 87
    else:
        num_results = 88
    assert len(check_results) == num_results
예제 #6
0
def test_codeanalysis_latin():
    """Test codeanalysis with pyflakes and pep8."""
    code = io.open(TEST_FILE_LATIN, encoding="iso-8859-1").read()
    check_results = (check_with_pyflakes(code, TEST_FILE_LATIN)
                     + check_with_pep8(code, TEST_FILE_LATIN)
                     + find_tasks(code))
    if PY2:
        num_results = 1
    else:
        num_results = 2
    assert len(check_results) == num_results
예제 #7
0
def construct_editor(*args, **kwargs):
    app = qapplication()
    editor = CodeEditor(parent=None)
    kwargs['language'] = 'Python'
    editor.setup_editor(*args, **kwargs)

    text = ("def some_function():\n"
            "    \n"  # W293 trailing spaces
            "    a = 1 # a comment\n"  # E261 two spaces before inline comment
            "\n"
            "    a += s\n"  # Undefined variable s
            "    return a\n"
            )
    editor.set_text(text)
    source_code = to_binary_string(editor.toPlainText())
    results = check_with_pyflakes(source_code) + check_with_pep8(source_code)
    editor.process_code_analysis(results)

    return editor
예제 #8
0
def construct_editor(*args, **kwargs):
    app = qapplication()
    editor = CodeEditor(parent=None)
    kwargs['language'] = 'Python'
    editor.setup_editor(*args, **kwargs)

    text = (
        "def some_function():\n"
        "    \n"  # W293 trailing spaces
        "    a = 1 # a comment\n"  # E261 two spaces before inline comment
        "\n"
        "    a += s\n"  # Undefined variable s
        "    return a\n")
    editor.set_text(text)
    source_code = to_binary_string(editor.toPlainText())
    results = check_with_pyflakes(source_code) + check_with_pep8(source_code)
    editor.process_code_analysis(results)

    return editor