def test_correct_zero_div(
    assert_errors,
    parse_ast_tree,
    expression,
    default_options,
):
    """Testing that there is no useless zero div."""
    tree = parse_ast_tree(usage_template.format(expression))

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

    assert_errors(visitor, [])
def test_meaningless_math(
    assert_errors,
    parse_ast_tree,
    expression,
    default_options,
):
    """Testing that there is no useless zero div."""
    tree = parse_ast_tree(usage_template.format(expression))

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

    assert_errors(visitor, [MeaninglessNumberOperationViolation])
Пример #3
0
def test_plus_sign_before_numbers_valid(
    assert_errors,
    parse_ast_tree,
    code,
    number,
    default_options,
    mode,
):
    """Testing that there is no useless plus sign before a number."""
    tree = parse_ast_tree(mode(code.format(number)))

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

    assert_errors(visitor, [])