Exemplo n.º 1
0
def test_correct_fields(
    assert_errors,
    parse_ast_tree,
    default_options,
    code,
    field1,
    field2,
):
    """Testing that correct fields are allowed."""
    tree = parse_ast_tree(code.format(field1, field2))

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

    assert_errors(visitor, [])
Exemplo n.º 2
0
def test_safe_fields(
    assert_errors,
    parse_ast_tree,
    default_options,
    code,
    field1,
    field2,
):
    """Testing that safe fields can be used everywhere."""
    tree = parse_ast_tree(code.format(field1, field2))

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

    assert_errors(visitor, [])
Exemplo n.º 3
0
def test_incorrect_fields(
    assert_errors,
    assert_error_text,
    parse_ast_tree,
    default_options,
    code,
    field_name,
):
    """Testing that incorrect fields are prohibited."""
    tree = parse_ast_tree(code.format(field_name, field_name))

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

    assert_errors(visitor, [ShadowedClassAttributeViolation])
    assert_error_text(visitor, field_name)