def test_correct_function_arguments(assert_errors, parse_ast_tree, code): """Testing that function can have normal arguments.""" tree = parse_ast_tree(code.format('xy', 'normal_name')) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [])
def test_private_function_names( assert_errors, parse_ast_tree, code, ): """Testing that function can not have too short names.""" tree = parse_ast_tree(code.format('__hidden')) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [PrivateNameViolation])
def test_private_variable_names( assert_errors, parse_ast_tree, code, ): """Testing that variable can not have private names.""" tree = parse_ast_tree(code.format('__private_value')) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [PrivateNameViolation])
def test_correct_variable_name( assert_errors, parse_ast_tree, code, correct_name, ): """Testing that variable can have normal names.""" tree = parse_ast_tree(code.format(correct_name)) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [])
def test_too_short_variable_names( assert_errors, parse_ast_tree, short_name, code, ): """Testing that variable can not have too short names.""" tree = parse_ast_tree(code.format(short_name)) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [TooShortVariableNameViolation])
def test_wrong_variable_names( assert_errors, parse_ast_tree, bad_name, code, ): """Testing that variable can not have blacklisted names.""" tree = parse_ast_tree(code.format(bad_name)) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [WrongVariableNameViolation])
def test_too_short_attribute_names( assert_errors, parse_ast_tree, short_name, code, error, ): """Testing that attribute can not have too short names.""" tree = parse_ast_tree(code.format(short_name)) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [error])
def test_wrong_attributes_names( assert_errors, parse_ast_tree, bad_name, code, error, ): """Testing that attribute can not have blacklisted names.""" tree = parse_ast_tree(code.format(bad_name)) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [error])
def test_private_function_arguments( assert_errors, parse_ast_tree, code, ): """Testing that function can not have private arguments.""" tree = parse_ast_tree(code.format('__private', '__name')) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [ PrivateNameViolation, PrivateNameViolation, ])
def test_too_short_function_arguments( assert_errors, parse_ast_tree, short_name, code, ): """Testing that function can not have too short arguments.""" tree = parse_ast_tree(code.format(short_name, 'data')) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [ TooShortVariableNameViolation, WrongVariableNameViolation, ])
def test_wrong_function_arguments( assert_errors, parse_ast_tree, bad_name, code, ): """Testing that function can not have blacklisted arguments.""" tree = parse_ast_tree(code.format('x', bad_name)) visiter = WrongNameVisitor() visiter.visit(tree) assert_errors(visiter, [ TooShortVariableNameViolation, WrongVariableNameViolation, ])