Esempio n. 1
0
def test_elif_correct_count(
    assert_errors,
    parse_ast_tree,
    code,
    default_options,
    mode,
):
    """Testing that all `if`/`elif`/`else` is allowed."""
    tree = parse_ast_tree(mode(code))

    visitor = ElifVisitor(default_options, tree=tree)
    visitor.run()

    assert_errors(visitor, [])
Esempio n. 2
0
def test_elif_incorrect_count(
    assert_errors,
    assert_error_text,
    parse_ast_tree,
    code,
    default_options,
):
    """Testing that incorrect number of `elif` is restricted."""
    tree = parse_ast_tree(code)

    visitor = ElifVisitor(default_options, tree=tree)
    visitor.run()

    assert_errors(visitor, [TooManyElifsViolation])
    assert_error_text(visitor, '4')