Exemple #1
0
def test_if_else_implict(
    assert_errors,
    default_options,
    parse_tokens,
):
    """Testing to make sure implicit if works."""
    tokens = parse_tokens(code_implict_if_else)

    visitor = IfElseVisitor(default_options, tokens)
    visitor.run()

    assert_errors(visitor, [ImplicitElifViolation])
Exemple #2
0
def test_if_else_one_line(
    assert_errors,
    default_options,
    parse_tokens,
):
    """Testing to see if ``if`` statement code is on one line."""
    tokens = parse_tokens(code_that_breaks)

    visitor = IfElseVisitor(default_options, tokens)
    visitor.run()

    assert_errors(visitor, [ImplicitElifViolation])
Exemple #3
0
def test_false_positives_are_ignored(
    code,
    assert_errors,
    parse_tokens,
    default_options,
):
    """Testing regular conditions."""
    file_tokens = parse_tokens(code, do_compile=False)

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

    assert_errors(visitor, [])
Exemple #4
0
def test_implicit_elif_statements(
    code,
    assert_errors,
    parse_tokens,
    default_options,
):
    """Testing implicit `elif` conditions."""
    file_tokens = parse_tokens(code)

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

    assert_errors(visitor, [ImplicitElifViolation])
Exemple #5
0
def test_correct_if_statements(
    code,
    assert_errors,
    parse_tokens,
    default_options,
):
    """Testing regular conditions."""
    file_tokens = parse_tokens(code)

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

    assert_errors(visitor, [])