def test_correct_empty_lambda_definition( assert_errors, parse_ast_tree, inner_def, default_options, ): """Testing correct empty lambdas are not reported.""" tree = parse_ast_tree(template.format('lambda', inner_def)) visitor = UselessLambdaDefinitionVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_wrong_lambda( assert_errors, parse_ast_tree, code, default_options, ): """Testing that isinstance is callable with correct types.""" tree = parse_ast_tree(code) visitor = UselessLambdaDefinitionVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [ImplicitPrimitiveViolation])
def test_incorrect_lambda_definition( assert_errors, parse_ast_tree, lambda_def, call_def, default_options, ): """Testing useless lambdas are reported.""" tree = parse_ast_tree(template.format(lambda_def, call_def)) visitor = UselessLambdaDefinitionVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [UselessLambdaViolation])