Commit 4387e4e0 authored by Julien Muchembled's avatar Julien Muchembled

Shorten traceback of ignored exceptions

parent 73e8af9e
......@@ -41,6 +41,16 @@ logger = logging.getLogger('networkcache')
logger.setLevel(logging.INFO)
class short_exc_info(tuple):
def __str__(self):
t, v, tb = self
filename, lineno, name, line = traceback.extract_tb(tb, 1)[0]
l = ['%s:%s\n' % (filename, lineno)]
l += traceback.format_exception_only(t, v)
return ''.join(l).rstrip()
class NetworkcacheClient(object):
'''
NetworkcacheClient is a wrapper for httplib.
......@@ -108,7 +118,8 @@ class NetworkcacheClient(object):
if isinstance(v, NetworkcacheException):
logger.info(*v.args)
else:
logger.info("ignored unhandled exception", exc_info=(t, v, tb))
logger.info("ignored unhandled exception at %s",
short_exc_info((t, v, tb)))
return True
def _request(self, where, name=None, data=None, headers=None):
......
......@@ -194,7 +194,7 @@ class OnlineMixin:
del self.handler
def assertRaised(self, exc_type):
self.assertEqual(exc_type, self.handler.buffer.pop(0).exc_info[0])
self.assertIs(exc_type, self.handler.buffer.pop(0).args[0][0])
def assertLog(self, msg=None):
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment