def test_TryExceptProcess_04():
    src = """
if 1:
    if 1:
        if 1:
            try:
                bim()
            except IndexError as exy:
                bam()
                raise
    """
    nodes = parseSource(src)
    fixIndents(nodes)
    cvtr = TryExceptConverter()
    matches = cvtr.gather(nodes)
    cvtr.processAll(matches)
    # dumpTree( nodes )
    # dumpNodes( nodes )
    assert nodesToLines(nodes) == [
        "if 1:",
        "    if 1:",
        "        if 1:",
        "            try {",
        "                bim()",
        "            } catch( exy ) /* IndexError */ {",
        "                bam()",
        "                raise",
        "            }",
    ]
def test_TryExceptProcess_02():
    src = """
        try:
            bim()
        except ( IndexError, KeyError ):
            bam()
            raise
        finally:
            bom()
        return 123
    """
    nodes = parseSource(src)
    cvtr = TryExceptConverter()
    matches = cvtr.gather(nodes)
    cvtr.processAll(matches)
    # dumpTree( nodes )
    # dumpNodes( nodes )
    assert nodesToLines(nodes) == [
        "try {",
        "    bim()",
        "} catch( e ) /* ( IndexError, KeyError ) */ {",
        "    bam()",
        "    raise",
        "} finally {",
        "    bom()",
        "}",
        "return 123",
    ]
def test_TryExceptProcess_03():
    src = """
        try:
            getattr( obj, 'bom' )
        except:
            pass
    """
    nodes = parseSource(src)
    cvtr = TryExceptConverter()
    matches = cvtr.gather(nodes)
    cvtr.processAll(matches)
    # dumpTree( nodes )
    # dumpNodes( nodes )
    assert nodesToLines(nodes) == [
        "try {",
        "    getattr( obj, 'bom' )",
        "} catch( e ) {",
        "    pass",
        "}",
    ]