@wraps(f)
def wrapper():
    tmppy_source = _get_function_body(f)
    actual_source_lines = []
    expected_error_regex = None
    expected_error_line = None
    expected_note_by_line = dict()
    for (line_index, line) in enumerate(tmppy_source.splitlines()):
        error_regex_marker = ' # error: '
        note_regex_marker = ' # note: '
        if (error_regex_marker in line):
            if expected_error_regex:
                pytest.fail('Multiple expected errors in the same test are not supported', pytrace=False)
            [line, expected_error_regex] = line.split(error_regex_marker)
            expected_error_line = (line_index + 1)
        elif (note_regex_marker in line):
            [line, expected_note_regex] = line.split(note_regex_marker)
            expected_note_by_line[(line_index + 1)] = expected_note_regex
        actual_source_lines.append(line)
    if (not expected_error_regex):
        pytest.fail(textwrap.dedent('                    assert_conversion_fails was used, but no expected error regex was found.\n                    \n                    TMPPy source:\n                    {tmppy_source}\n                    ').format(tmppy_source=add_line_numbers(tmppy_source)), pytrace=False)
    try:
        (module_ir2, module_ir1) = _convert_tmppy_source_to_ir('\n'.join(actual_source_lines), create_identifier_generator())
        e = None
    except ast_to_ir3.CompilationError as e1:
        e = e1
    if (not e):
        pytest.fail(textwrap.dedent('                    Expected an exception, 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_ir1}\n                    ').format(tmppy_source=add_line_numbers(tmppy_source), tmppy_ir2=str(module_ir2), tmppy_ir1=str(module_ir1)), pytrace=False)
    py2tmp_diagnostics = _split_list(e.args[0].splitlines(), num_elems_in_chunk=3)
    error_diagnostic = py2tmp_diagnostics[0]
    expected_error_regex = ('<unknown>:[0-9]*:[0-9]*: error: ' + expected_error_regex)
    if (not re.match(expected_error_regex, error_diagnostic[0])):
        pytest.fail(textwrap.dedent("                    An exception was thrown, but it didn't match the expected error regex.\n                    Expected error regex: {expected_error_regex}\n                    Actual error:\n                    {actual_error}\n                    \n                    TMPPy source:\n                    {tmppy_source}\n                    ").format(expected_error_regex=expected_error_regex, actual_error='\n'.join(error_diagnostic), tmppy_source=add_line_numbers(tmppy_source)), pytrace=False)
    matches = re.match('<unknown>:([0-9]*):', error_diagnostic[0])
    actual_error_line = int(matches.group(1))
    if (expected_error_line != actual_error_line):
        pytest.fail(textwrap.dedent('                    An exception matching the expected regex was thrown, but the error mentioned the wrong line: {actual_error_line} was reported instead of {expected_error_line}\n                    Expected error regex: {expected_error_regex}\n                    Actual error:\n                    {actual_error}\n                    \n                    TMPPy source:\n                    {tmppy_source}\n                    ').format(actual_error_line=actual_error_line, expected_error_line=expected_error_line, expected_error_regex=expected_error_regex, actual_error='\n'.join(error_diagnostic), tmppy_source=add_line_numbers(tmppy_source)), pytrace=False)
    actual_note_by_line = {_get_line_from_diagnostic(note[0]): note for note in py2tmp_diagnostics[1:]}
    for (expected_note_line, expected_note_regex) in expected_note_by_line.items():
        actual_note = actual_note_by_line.get(expected_note_line)
        if (not actual_note):
            raise Exception(('Expected the note %s on line %s but no note was emitted mentioning this line. Emitted notes: %s' % (expected_note_regex, expected_note_line, json.dumps(actual_note_by_line, indent=4))))
        expected_note_regex = ('<unknown>:[0-9]*:[0-9]*: note: ' + expected_note_regex)
        if (not re.match(expected_note_regex, actual_note[0])):
            pytest.fail(textwrap.dedent("                        A note diagnostic was emitted, but it didn't match the expected note regex.\n                        Expected note regex: {expected_note_regex}\n                        Actual note:\n                        {actual_note}\n                        \n                        TMPPy source:\n                        {tmppy_source}\n                        ").format(expected_note_regex=expected_note_regex, actual_note='\n'.join(actual_note), tmppy_source=add_line_numbers(tmppy_source)), pytrace=False)
    for (actual_note_line, actual_note) in actual_note_by_line.items():
        expected_note = expected_note_by_line.get(actual_note_line)
        if (not expected_note):
            pytest.fail(textwrap.dedent('                        Unexpected note:\n                        {actual_note}\n                        \n                        TMPPy source:\n                        {tmppy_source}\n                        ').format(actual_note='\n'.join(actual_note), tmppy_source=add_line_numbers(tmppy_source), pytrace=False))
@wraps(f)
def wrapper():
    tmppy_source = _get_function_body(f)
    actual_source_lines = []
    expected_error_regex = None
    expected_error_line = None
    expected_note_by_line = dict()
    for (line_index, line) in enumerate(tmppy_source.splitlines()):
        error_regex_marker = ' # error: '
        note_regex_marker = ' # note: '
        if (error_regex_marker in line):
            if expected_error_regex:
                pytest.fail('Multiple expected errors in the same test are not supported', pytrace=False)
            [line, expected_error_regex] = line.split(error_regex_marker)
            expected_error_line = (line_index + 1)
        elif (note_regex_marker in line):
            [line, expected_note_regex] = line.split(note_regex_marker)
            expected_note_by_line[(line_index + 1)] = expected_note_regex
        actual_source_lines.append(line)
    if (not expected_error_regex):
        pytest.fail(textwrap.dedent('                    assert_conversion_fails was used, but no expected error regex was found.\n                    \n                    TMPPy source:\n                    {tmppy_source}\n                    ').format(tmppy_source=add_line_numbers(tmppy_source)), pytrace=False)
    try:
        (module_ir2, module_ir1) = _convert_tmppy_source_to_ir('\n'.join(actual_source_lines), create_identifier_generator())
        e = None
    except ast_to_ir3.CompilationError as e1:
        e = e1
    if (not e):
        pytest.fail(textwrap.dedent('                    Expected an exception, 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_ir1}\n                    ').format(tmppy_source=add_line_numbers(tmppy_source), tmppy_ir2=str(module_ir2), tmppy_ir1=str(module_ir1)), pytrace=False)
    py2tmp_diagnostics = _split_list(e.args[0].splitlines(), num_elems_in_chunk=3)
    error_diagnostic = py2tmp_diagnostics[0]
    expected_error_regex = ('<unknown>:[0-9]*:[0-9]*: error: ' + expected_error_regex)
    if (not re.match(expected_error_regex, error_diagnostic[0])):
        pytest.fail(textwrap.dedent("                    An exception was thrown, but it didn't match the expected error regex.\n                    Expected error regex: {expected_error_regex}\n                    Actual error:\n                    {actual_error}\n                    \n                    TMPPy source:\n                    {tmppy_source}\n                    ").format(expected_error_regex=expected_error_regex, actual_error='\n'.join(error_diagnostic), tmppy_source=add_line_numbers(tmppy_source)), pytrace=False)
    matches = re.match('<unknown>:([0-9]*):', error_diagnostic[0])
    actual_error_line = int(matches.group(1))
    if (expected_error_line != actual_error_line):
        pytest.fail(textwrap.dedent('                    An exception matching the expected regex was thrown, but the error mentioned the wrong line: {actual_error_line} was reported instead of {expected_error_line}\n                    Expected error regex: {expected_error_regex}\n                    Actual error:\n                    {actual_error}\n                    \n                    TMPPy source:\n                    {tmppy_source}\n                    ').format(actual_error_line=actual_error_line, expected_error_line=expected_error_line, expected_error_regex=expected_error_regex, actual_error='\n'.join(error_diagnostic), tmppy_source=add_line_numbers(tmppy_source)), pytrace=False)
    actual_note_by_line = {_get_line_from_diagnostic(note[0]): note for note in py2tmp_diagnostics[1:]}
    for (expected_note_line, expected_note_regex) in expected_note_by_line.items():
        actual_note = actual_note_by_line.get(expected_note_line)
        if (not actual_note):
            raise Exception(('Expected the note %s on line %s but no note was emitted mentioning this line. Emitted notes: %s' % (expected_note_regex, expected_note_line, json.dumps(actual_note_by_line, indent=4))))
        expected_note_regex = ('<unknown>:[0-9]*:[0-9]*: note: ' + expected_note_regex)
        if (not re.match(expected_note_regex, actual_note[0])):
            pytest.fail(textwrap.dedent("                        A note diagnostic was emitted, but it didn't match the expected note regex.\n                        Expected note regex: {expected_note_regex}\n                        Actual note:\n                        {actual_note}\n                        \n                        TMPPy source:\n                        {tmppy_source}\n                        ").format(expected_note_regex=expected_note_regex, actual_note='\n'.join(actual_note), tmppy_source=add_line_numbers(tmppy_source)), pytrace=False)
    for (actual_note_line, actual_note) in actual_note_by_line.items():
        expected_note = expected_note_by_line.get(actual_note_line)
        if (not expected_note):
            pytest.fail(textwrap.dedent('                        Unexpected note:\n                        {actual_note}\n                        \n                        TMPPy source:\n                        {tmppy_source}\n                        ').format(actual_note='\n'.join(actual_note), tmppy_source=add_line_numbers(tmppy_source), pytrace=False))