示例#1
0
def test_correct_accesss(
    assert_errors,
    parse_ast_tree,
    code,
    options,
    mode,
):
    """Testing that expressions with correct access level work well."""
    tree = parse_ast_tree(mode(code))

    option_values = options(max_access_level=4)
    visitor = AccessVisitor(option_values, tree=tree)
    visitor.run()

    assert_errors(visitor, [])
示例#2
0
def test_incorrect_access(
    assert_errors,
    assert_error_text,
    parse_ast_tree,
    code,
    access_level,
    options,
    mode,
):
    """Testing that violations are raised when reaching too deep access."""
    tree = parse_ast_tree(mode(code))

    option_values = options(max_access_level=3)
    visitor = AccessVisitor(option_values, tree=tree)
    visitor.run()

    assert_errors(visitor, [TooDeepAccessViolation])
    assert_error_text(visitor, str(access_level))