filter out and test exception printing
--HG-- branch : trunk
This commit is contained in:
parent
e30aeed876
commit
73fc2f01f2
|
@ -237,6 +237,16 @@ def _setupmessages():
|
||||||
|
|
||||||
_setupmessages()
|
_setupmessages()
|
||||||
|
|
||||||
|
def geterrortext(excinfo):
|
||||||
|
try:
|
||||||
|
l = traceback.format_exception(*excinfo)
|
||||||
|
errortext = "".join(l)
|
||||||
|
except sysex:
|
||||||
|
raise
|
||||||
|
except:
|
||||||
|
errortext = '%s: %s' % (excinfo[0].__name__,
|
||||||
|
excinfo[1])
|
||||||
|
return errortext
|
||||||
|
|
||||||
class RemoteError(EOFError):
|
class RemoteError(EOFError):
|
||||||
""" Contains an Exceptions from the other side. """
|
""" Contains an Exceptions from the other side. """
|
||||||
|
@ -618,15 +628,6 @@ class BaseGateway(object):
|
||||||
except:
|
except:
|
||||||
sys.stderr.write("exception during tracing\n")
|
sys.stderr.write("exception during tracing\n")
|
||||||
|
|
||||||
def _traceex(self, excinfo):
|
|
||||||
try:
|
|
||||||
l = traceback.format_exception(*excinfo)
|
|
||||||
errortext = "".join(l)
|
|
||||||
except:
|
|
||||||
errortext = '%s: %s' % (excinfo[0].__name__,
|
|
||||||
excinfo[1])
|
|
||||||
self._trace(errortext)
|
|
||||||
|
|
||||||
def _thread_receiver(self):
|
def _thread_receiver(self):
|
||||||
""" thread to read and handle Messages half-sync-half-async. """
|
""" thread to read and handle Messages half-sync-half-async. """
|
||||||
self._trace("starting to receive")
|
self._trace("starting to receive")
|
||||||
|
@ -646,7 +647,7 @@ class BaseGateway(object):
|
||||||
except EOFError:
|
except EOFError:
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
self._traceex(self.exc_info())
|
self._trace(geterrortext(self.exc_info()))
|
||||||
break
|
break
|
||||||
finally:
|
finally:
|
||||||
# XXX we need to signal fatal error states to
|
# XXX we need to signal fatal error states to
|
||||||
|
@ -669,7 +670,7 @@ class BaseGateway(object):
|
||||||
msg.writeto(self._io)
|
msg.writeto(self._io)
|
||||||
except:
|
except:
|
||||||
excinfo = self.exc_info()
|
excinfo = self.exc_info()
|
||||||
self._traceex(excinfo)
|
self._trace(geterrortext(excinfo))
|
||||||
else:
|
else:
|
||||||
self._trace('sent -> %r' % msg)
|
self._trace('sent -> %r' % msg)
|
||||||
|
|
||||||
|
@ -741,8 +742,7 @@ class BaseGateway(object):
|
||||||
except:
|
except:
|
||||||
excinfo = self.exc_info()
|
excinfo = self.exc_info()
|
||||||
self._trace("got exception %s" % excinfo[1])
|
self._trace("got exception %s" % excinfo[1])
|
||||||
l = traceback.format_exception(*excinfo)
|
errortext = geterrortext(excinfo)
|
||||||
errortext = "".join(l)
|
|
||||||
channel.close(errortext)
|
channel.close(errortext)
|
||||||
else:
|
else:
|
||||||
channel.close()
|
channel.close()
|
||||||
|
|
|
@ -85,6 +85,26 @@ def test_rinfo_source(pythonpath, tmpdir):
|
||||||
print (out)
|
print (out)
|
||||||
assert "all passed" in out
|
assert "all passed" in out
|
||||||
|
|
||||||
|
def test_geterrortext(pythonpath, tmpdir):
|
||||||
|
check = tmpdir.join("check.py")
|
||||||
|
check.write(py.code.Source(gateway_base, """
|
||||||
|
class Arg:
|
||||||
|
pass
|
||||||
|
errortext = geterrortext((Arg, "1", 4))
|
||||||
|
assert "Arg" in errortext
|
||||||
|
import sys
|
||||||
|
try:
|
||||||
|
raise ValueError("17")
|
||||||
|
except ValueError:
|
||||||
|
excinfo = sys.exc_info()
|
||||||
|
s = geterrortext(excinfo)
|
||||||
|
assert "17" in s
|
||||||
|
print ("all passed")
|
||||||
|
"""))
|
||||||
|
out = pythonpath.sysexec(check)
|
||||||
|
print (out)
|
||||||
|
assert "all passed" in out
|
||||||
|
|
||||||
class TestExecnetEvents:
|
class TestExecnetEvents:
|
||||||
def test_popengateway(self, _pytest):
|
def test_popengateway(self, _pytest):
|
||||||
rec = _pytest.gethookrecorder(ExecnetAPI)
|
rec = _pytest.gethookrecorder(ExecnetAPI)
|
||||||
|
|
Loading…
Reference in New Issue