aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--netlib/debug.py9
-rw-r--r--test/netlib/test_debug.py4
2 files changed, 9 insertions, 4 deletions
diff --git a/netlib/debug.py b/netlib/debug.py
index 7a7d3479..657d4465 100644
--- a/netlib/debug.py
+++ b/netlib/debug.py
@@ -38,7 +38,7 @@ def sysinfo():
return "\n".join(data)
-def dump_info(signal=None, frame=None, file=sys.stdout): # pragma: no cover
+def dump_info(signal=None, frame=None, file=sys.stdout, testing=False): # pragma: no cover
print("****************************************************", file=file)
print("Summary", file=file)
print("=======", file=file)
@@ -94,8 +94,11 @@ def dump_info(signal=None, frame=None, file=sys.stdout): # pragma: no cover
print(i[1], i[0])
print("****************************************************", file=file)
+ if not testing:
+ sys.exit(1)
-def dump_stacks(signal=None, frame=None, file=sys.stdout):
+
+def dump_stacks(signal=None, frame=None, file=sys.stdout, testing=False):
id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
code = []
for threadId, stack in sys._current_frames().items():
@@ -109,6 +112,8 @@ def dump_stacks(signal=None, frame=None, file=sys.stdout):
if line:
code.append(" %s" % (line.strip()))
print("\n".join(code), file=file)
+ if not testing:
+ sys.exit(1)
def register_info_dumpers():
diff --git a/test/netlib/test_debug.py b/test/netlib/test_debug.py
index 51710da0..9ceaace9 100644
--- a/test/netlib/test_debug.py
+++ b/test/netlib/test_debug.py
@@ -6,13 +6,13 @@ from netlib import debug
def test_dump_info():
cs = StringIO()
- debug.dump_info(None, None, file=cs)
+ debug.dump_info(None, None, file=cs, testing=True)
assert cs.getvalue()
def test_dump_stacks():
cs = StringIO()
- debug.dump_stacks(None, None, file=cs)
+ debug.dump_stacks(None, None, file=cs, testing=True)
assert cs.getvalue()