Esempio n. 1
0
     raise error("Expecting this call to fail!")
 except pythoncom.com_error, com_exc:
     if com_exc.hresult != winerror.E_UNEXPECTED:
         raise error(
             "Calling the object natively did not yield the correct scode",
             com_exc)
     exc = com_exc.excepinfo
     if not exc or exc[-1] != winerror.E_UNEXPECTED:
         raise error(
             "The scode element of the exception tuple did not yield the correct scode",
             com_exc)
     if exc[2] != "Not today":
         raise error(
             "The description in the exception tuple did not yield the correct string",
             com_exc)
 cap = CaptureWriter()
 try:
     cap.capture()
     try:
         com_server.Commit(0)
     finally:
         cap.release()
     raise error("Expecting this call to fail!")
 except pythoncom.com_error, com_exc:
     if com_exc.hresult != winerror.E_FAIL:
         raise error("The hresult was not E_FAIL for an internal error",
                     com_exc)
     if com_exc.excepinfo[1] != "Python COM Server Internal Error":
         raise error(
             "The description in the exception tuple did not yield the correct string",
             com_exc)
Esempio n. 2
0
def test():
    # Call via a native interface.
    com_server = wrap(TestServer(), pythoncom.IID_IStream)
    try:
        com_server.Clone()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error, com_exc:
        if com_exc.hresult != winerror.E_UNEXPECTED:
            raise error("Calling the object natively did not yield the correct scode", com_exc)
        exc = com_exc.excepinfo
        if not exc or exc[-1] != winerror.E_UNEXPECTED:
            raise error("The scode element of the exception tuple did not yield the correct scode", com_exc)
        if exc[2] != "Not today":
            raise error("The description in the exception tuple did not yield the correct string", com_exc)
    cap = CaptureWriter()
    try:
        cap.capture()
        try:
            com_server.Commit(0)
        finally:
            cap.release()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error, com_exc:
        if com_exc.hresult != winerror.E_FAIL:
            raise error("The hresult was not E_FAIL for an internal error", com_exc)
        if com_exc.excepinfo[1] != "Python COM Server Internal Error":
            raise error("The description in the exception tuple did not yield the correct string", com_exc)
    # Check we saw a traceback in stderr
    if cap.get_captured().find("Traceback")<0:
        raise error("Could not find a traceback in stderr: %r" % (cap.get_captured(),))
Esempio n. 3
0
def test():
    # Call via a native interface.
    com_server = wrap(TestServer(), pythoncom.IID_IStream)
    try:
        com_server.Clone()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error as com_exc:
        if com_exc.hresult != winerror.E_UNEXPECTED:
            raise error("Calling the object natively did not yield the correct scode", com_exc)
        exc = com_exc.excepinfo
        if not exc or exc[-1] != winerror.E_UNEXPECTED:
            raise error("The scode element of the exception tuple did not yield the correct scode", com_exc)
        if exc[2] != "Not today":
            raise error("The description in the exception tuple did not yield the correct string", com_exc)
    cap = CaptureWriter()
    try:
        cap.capture()
        try:
            com_server.Commit(0)
        finally:
            cap.release()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error as com_exc:
        if com_exc.hresult != winerror.E_FAIL:
            raise error("The hresult was not E_FAIL for an internal error", com_exc)
        if com_exc.excepinfo[1] != "Python COM Server Internal Error":
            raise error("The description in the exception tuple did not yield the correct string", com_exc)
    # Check we saw a traceback in stderr
    if cap.get_captured().find("Traceback") < 0:
        raise error("Could not find a traceback in stderr: %r" % (cap.get_captured(),))

    # Now do it all again, but using IDispatch
    com_server = Dispatch(wrap(TestServer()))
    try:
        com_server.Clone()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error as com_exc:
        if com_exc.hresult != winerror.DISP_E_EXCEPTION:
            raise error("Calling the object via IDispatch did not yield the correct scode", com_exc)
        exc = com_exc.excepinfo
        if not exc or exc[-1] != winerror.E_UNEXPECTED:
            raise error("The scode element of the exception tuple did not yield the correct scode", com_exc)
        if exc[2] != "Not today":
            raise error("The description in the exception tuple did not yield the correct string", com_exc)

    cap.clear()
    try:
        cap.capture()
        try:
            com_server.Commit(0)
        finally:
            cap.release()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error as com_exc:
        if com_exc.hresult != winerror.DISP_E_EXCEPTION:
            raise error("Calling the object via IDispatch did not yield the correct scode", com_exc)
        exc = com_exc.excepinfo
        if not exc or exc[-1] != winerror.E_FAIL:
            raise error("The scode element of the exception tuple did not yield the correct scode", com_exc)
        if exc[1] != "Python COM Server Internal Error":
            raise error("The description in the exception tuple did not yield the correct string", com_exc)
    # Check we saw a traceback in stderr
    if cap.get_captured().find("Traceback") < 0:
        raise error("Could not find a traceback in stderr: %r" % (cap.get_captured(),))
Esempio n. 4
0
def test():
    # Call via a native interface.
    com_server = wrap(TestServer(), pythoncom.IID_IStream)
    try:
        com_server.Clone()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error as com_exc:
        if com_exc.hresult != winerror.E_UNEXPECTED:
            raise error(
                "Calling the object natively did not yield the correct scode",
                com_exc)
        exc = com_exc.excepinfo
        if not exc or exc[-1] != winerror.E_UNEXPECTED:
            raise error(
                "The scode element of the exception tuple did not yield the correct scode",
                com_exc)
        if exc[2] != "Not today":
            raise error(
                "The description in the exception tuple did not yield the correct string",
                com_exc)
    cap = CaptureWriter()
    try:
        cap.capture()
        try:
            com_server.Commit(0)
        finally:
            cap.release()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error as com_exc:
        if com_exc.hresult != winerror.E_FAIL:
            raise error("The hresult was not E_FAIL for an internal error",
                        com_exc)
        if com_exc.excepinfo[1] != "Python COM Server Internal Error":
            raise error(
                "The description in the exception tuple did not yield the correct string",
                com_exc)
    # Check we saw a traceback in stderr
    if cap.get_captured().find("Traceback") < 0:
        raise error("Could not find a traceback in stderr: %r" %
                    (cap.get_captured(), ))

    # Now do it all again, but using IDispatch
    com_server = Dispatch(wrap(TestServer()))
    try:
        com_server.Clone()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error as com_exc:
        if com_exc.hresult != winerror.DISP_E_EXCEPTION:
            raise error(
                "Calling the object via IDispatch did not yield the correct scode",
                com_exc)
        exc = com_exc.excepinfo
        if not exc or exc[-1] != winerror.E_UNEXPECTED:
            raise error(
                "The scode element of the exception tuple did not yield the correct scode",
                com_exc)
        if exc[2] != "Not today":
            raise error(
                "The description in the exception tuple did not yield the correct string",
                com_exc)

    cap.clear()
    try:
        cap.capture()
        try:
            com_server.Commit(0)
        finally:
            cap.release()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error as com_exc:
        if com_exc.hresult != winerror.DISP_E_EXCEPTION:
            raise error(
                "Calling the object via IDispatch did not yield the correct scode",
                com_exc)
        exc = com_exc.excepinfo
        if not exc or exc[-1] != winerror.E_FAIL:
            raise error(
                "The scode element of the exception tuple did not yield the correct scode",
                com_exc)
        if exc[1] != "Python COM Server Internal Error":
            raise error(
                "The description in the exception tuple did not yield the correct string",
                com_exc)
    # Check we saw a traceback in stderr
    if cap.get_captured().find("Traceback") < 0:
        raise error("Could not find a traceback in stderr: %r" %
                    (cap.get_captured(), ))
Esempio n. 5
0
def test():
    # Call via a native interface.
    com_server = wrap(TestServer(), pythoncom.IID_IStream)
    try:
        com_server.Clone()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error, com_exc:
        if com_exc.hresult != winerror.E_UNEXPECTED:
            raise error("Calling the object natively did not yield the correct scode", com_exc)
        exc = com_exc.excepinfo
        if not exc or exc[-1] != winerror.E_UNEXPECTED:
            raise error("The scode element of the exception tuple did not yield the correct scode", com_exc)
        if exc[2] != "Not today":
            raise error("The description in the exception tuple did not yield the correct string", com_exc)
    cap = CaptureWriter()
    try:
        cap.capture()
        try:
            com_server.Commit(0)
        finally:
            cap.release()
        raise error("Expecting this call to fail!")
    except pythoncom.com_error, com_exc:
        if com_exc.hresult != winerror.E_FAIL:
            raise error("The hresult was not E_FAIL for an internal error", com_exc)
        if com_exc.excepinfo[1] != "Python COM Server Internal Error":
            raise error("The description in the exception tuple did not yield the correct string", com_exc)
    # Check we saw a traceback in stderr
    if cap.get_captured().find("Traceback")<0:
        raise error("Could not find a traceback in stderr: %r" % (cap.get_captured(),))