def test_correct_count(
    assert_errors, parse_ast_tree, code, default_options,
):
    """Testing of correct base classes number."""
    tree = parse_ast_tree(code)

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

    assert_errors(visitor, [])
Esempio n. 2
0
def test_bad_number_custom_option(
    assert_errors,
    parse_ast_tree,
    code,
    options,
):
    """Testing of base classes number with custom options."""
    tree = parse_ast_tree(code)

    options = options(max_base_classes=5)
    visitor = ClassComplexityVisitor(options, tree=tree)
    visitor.run()

    assert_errors(visitor, [])
Esempio n. 3
0
def test_bad_number_default_option(
    assert_errors,
    assert_error_text,
    parse_ast_tree,
    code,
    default_options,
):
    """Testing of base classes number with default options."""
    tree = parse_ast_tree(code)

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

    assert_errors(visitor, [TooManyBaseClassesViolation])
    assert_error_text(visitor, '5')
def test_correct_attributes(
    assert_errors,
    parse_ast_tree,
    code,
    expression,
    options,
    mode,
):
    """Testing of correct base classes number."""
    tree = parse_ast_tree(mode(code.format(expression, expression)))

    option_values = options(max_attributes=1)
    visitor = ClassComplexityVisitor(option_values, tree=tree)
    visitor.run()

    assert_errors(visitor, [])
def test_wrong_attributes_count(
    assert_errors,
    assert_error_text,
    parse_ast_tree,
    code,
    expression1,
    expression2,
    options,
    mode,
):
    """Testing of correct base classes number."""
    tree = parse_ast_tree(mode(code.format(expression1, expression2)))

    option_values = options(max_attributes=1)
    visitor = ClassComplexityVisitor(option_values, tree=tree)
    visitor.run()

    assert_errors(visitor, [TooManyPublicAttributesViolation])
    assert_error_text(visitor, '2', option_values.max_attributes)