Esempio n. 1
0
def test_string_proper_line_breaks(
    parse_tokens,
    assert_errors,
    default_options,
    code,
):
    """Ensures that proper string's line break are fine."""
    file_tokens = parse_tokens(code)

    visitor = WrongKeywordTokenVisitor(
        default_options,
        file_tokens=file_tokens,
    )
    visitor.run()

    assert_errors(visitor, [])
Esempio n. 2
0
def test_string_wrong_line_breaks(
    parse_tokens,
    assert_errors,
    default_options,
    code,
):
    """Ensures that obsolete string's line break raise a violation."""
    file_tokens = parse_tokens(code)

    visitor = WrongKeywordTokenVisitor(
        default_options,
        file_tokens=file_tokens,
    )
    visitor.run()

    assert_errors(visitor, [LineCompriseCarriageReturnViolation])
def test_space_between_keyword_and_parens(
    parse_tokens,
    assert_errors,
    default_options,
    code,
):
    """Ensures that there's no violation if space in between."""
    file_tokens = parse_tokens(code, do_compile=False)

    visitor = WrongKeywordTokenVisitor(
        default_options,
        file_tokens=file_tokens,
    )
    visitor.run()

    assert_errors(visitor, [])
def test_missing_space(
    parse_tokens,
    assert_errors,
    default_options,
    code,
):
    """Ensures that parens right after keyword raise a warning."""
    file_tokens = parse_tokens(code, do_compile=False)

    visitor = WrongKeywordTokenVisitor(
        default_options,
        file_tokens=file_tokens,
    )
    visitor.run()

    assert_errors(visitor, [MissingSpaceBetweenKeywordAndParenViolation])
Esempio n. 5
0
def test_correct_dot_start(
    parse_tokens,
    assert_errors,
    default_options,
    code,
):
    """Ensures that lines can be started with other chars."""
    file_tokens = parse_tokens(code)

    visitor = WrongKeywordTokenVisitor(
        default_options,
        file_tokens=file_tokens,
    )
    visitor.run()

    assert_errors(visitor, [])
Esempio n. 6
0
def test_wrong_dot_start(
    parse_tokens,
    assert_errors,
    default_options,
    code,
):
    """Ensures that lines cannot be started with ``.`` char."""
    file_tokens = parse_tokens(code)

    visitor = WrongKeywordTokenVisitor(
        default_options,
        file_tokens=file_tokens,
    )
    visitor.run()

    assert_errors(visitor, [LineStartsWithDotViolation])