Brilliant, thanks :) On 6 June 2012 22:50, Tomer Filiba <[email protected]> wrote:
> hrmm, interesting. i'm have this problem too now, when running tests, and > i think i came up with a solution: vinegar will monkey-patch exception > classes so that their __str__ method would take care of the _remote_tb. you > can see the patch here: > > > https://github.com/tomerfiliba/rpyc/commit/3189021460d7ce7418a58c1a29eaeec01af2cdfd > > i'd love to get comments on that. > > ----------------------------------------------------------------- > > *Tomer Filiba* > tomerfiliba.com <http://www.facebook.com/tomerfiliba> > <http://il.linkedin.com/in/tomerfiliba> > > > > On Thu, May 31, 2012 at 3:17 AM, Oliver Drake <[email protected]> wrote: > >> Hey guys, >> I stumbled across a bit of an issue when writing integration tests >> using the unittest/unittest2 frameworks for my project that uses RPyC. >> If you get an unexpected exception on the server side, rpyc usually >> prints this out on the client side using sys.excepthook, however when >> running in unittest all exceptions are caught and stored by the >> framework, so sys.excepthook is never called. I solved this by >> extending test result class in my unittest file (should work for both >> unittest and unittest2): >> >> class RPyCTestResult(unittest.TextTestResult): >> def _exc_info_to_string(self, err, test): >> s = super(RPyCTestResult, self)._exc_info_to_string(err, test) >> exctype, value, tb = err >> if hasattr(value, "_remote_tb"): >> s += "\n========= Remote traceback ========\n" >> s += >> "\n--------------------------------\n\n".join(value._remote_tb) >> s += "===== End of Remote traceback ======\n" >> return s >> >> if __name__ == "__main__": >> >> unittest.main(testRunner=unittest.TextTestRunner(resultclass=RPyCTestResult)) >> >> Obviously this will only work if you run the python file directly >> (need to figure out how to integrate with nose). Cheers for writing a >> great RPC library btw, using rpyc has been a pleasurable experience :) >> Regards, >> Oliver >> > >
