def test_correct_return_statements( assert_errors, parse_ast_tree, code, default_options, mode, ): """Testing correct `return` statements.""" tree = parse_ast_tree(mode(code)) visitor = ConsistentReturningVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [])
def test_wrong_yield_statement( assert_errors, parse_ast_tree, code, default_options, mode, ): """Testing incorrect `yield` statements.""" tree = parse_ast_tree(mode(code)) visitor = ConsistentReturningVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [InconsistentYieldViolation])
def test_douple_wrong_return_statement( assert_errors, parse_ast_tree, default_options, mode, ): """Testing double incorrect `return` statements.""" tree = parse_ast_tree(mode(double_wrong_return)) visitor = ConsistentReturningVisitor(default_options, tree=tree) visitor.run() assert_errors(visitor, [ InconsistentReturnViolation, InconsistentReturnViolation, ])