def assert_conversion_fails_with_codegen_error(expected_error_regex: str):

    def eval(f):

        @wraps(f)
        def wrapper():
            tmppy_source = _get_function_body(f)
            try:
                (module_ir2, module_ir1, cpp_source) = _convert_to_cpp_expecting_success(tmppy_source)
                e = None
            except ir0.CodegenError as e1:
                e = e1
            if (not e):
                pytest.fail(textwrap.dedent('                        Expected a codegen error, but the _py2tmp conversion completed successfully.\n                        TMPPy source:\n                        {tmppy_source}\n                        \n                        TMPPy IR2:\n                        {tmppy_ir2}\n                        \n                        TMPPy IR1:\n                        {tmppy_ir2}\n                        \n                        C++ source:\n                        {cpp_source}\n                        ').format(tmppy_source=add_line_numbers(tmppy_source), tmppy_ir2=str(module_ir2), tmppy_ir1=str(module_ir1), cpp_source=add_line_numbers(cpp_source)), pytrace=False)
            if (not re.match(expected_error_regex, e.args[0])):
                pytest.fail(textwrap.dedent("                        A codegen error was emitted as expected, but it didn't match the expected note regex.\n                        Expected error regex: {expected_error_regex}\n                        Actual error:\n                        {actual_error}\n                        \n                        TMPPy source:\n                        {tmppy_source}\n\n                        TMPPy IR2:\n                        {tmppy_ir2}\n                        \n                        TMPPy IR1:\n                        {tmppy_ir1}\n                        \n                        C++ source:\n                        {cpp_source}\n                        ").format(expected_error_regex=expected_error_regex, actual_error=e.args[0], tmppy_source=add_line_numbers(tmppy_source), tmppy_ir2=str(module_ir2), tmppy_ir1=str(module_ir1), cpp_source=add_line_numbers(cpp_source)), pytrace=False)
        return wrapper
    return eval
def assert_conversion_fails_with_codegen_error(expected_error_regex: str):

    def eval(f):

        @wraps(f)
        def wrapper():
            tmppy_source = _get_function_body(f)
            try:
                (module_ir2, module_ir1, cpp_source) = _convert_to_cpp_expecting_success(tmppy_source)
                e = None
            except ir0.CodegenError as e1:
                e = e1
            if (not e):
                pytest.fail(textwrap.dedent('                        Expected a codegen error, but the _py2tmp conversion completed successfully.\n                        TMPPy source:\n                        {tmppy_source}\n                        \n                        TMPPy IR2:\n                        {tmppy_ir2}\n                        \n                        TMPPy IR1:\n                        {tmppy_ir2}\n                        \n                        C++ source:\n                        {cpp_source}\n                        ').format(tmppy_source=add_line_numbers(tmppy_source), tmppy_ir2=str(module_ir2), tmppy_ir1=str(module_ir1), cpp_source=add_line_numbers(cpp_source)), pytrace=False)
            if (not re.match(expected_error_regex, e.args[0])):
                pytest.fail(textwrap.dedent("                        A codegen error was emitted as expected, but it didn't match the expected note regex.\n                        Expected error regex: {expected_error_regex}\n                        Actual error:\n                        {actual_error}\n                        \n                        TMPPy source:\n                        {tmppy_source}\n\n                        TMPPy IR2:\n                        {tmppy_ir2}\n                        \n                        TMPPy IR1:\n                        {tmppy_ir1}\n                        \n                        C++ source:\n                        {cpp_source}\n                        ").format(expected_error_regex=expected_error_regex, actual_error=e.args[0], tmppy_source=add_line_numbers(tmppy_source), tmppy_ir2=str(module_ir2), tmppy_ir1=str(module_ir1), cpp_source=add_line_numbers(cpp_source)), pytrace=False)
        return wrapper
    return eval