Skip to content
Snippets Groups Projects
Commit 5733bac2 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

smarter tests

parent 8bea0041
No related branches found
No related tags found
No related merge requests found
......@@ -7,17 +7,19 @@ from satella.instrumentation import Traceback
logger = logging.getLogger(__name__)
def dump_frames_on(sig_no, stack_frame, output):
sys.stderr.write("Stack frame dump requested\n")
# noinspection PyProtectedMember
for frame in sys._current_frames():
sys.stderr.write("For stack frame %s" % (repr(frame),))
tb = Traceback(frame)
tb.pretty_print(output=output)
sys.stderr.write("End of stack frame dump\n")
def install_dump_frames_on(signal_number, output=sys.stderr):
"""
Instruct Python to dump all frames onto output, along with their local variables
upon receiving given signal
"""
def dump_frames_on(sig_no, stack_frame):
sys.stderr.write("Stack frame dump requested\n")
# noinspection PyProtectedMember
for frame in sys._current_frames():
sys.stderr.write("For stack frame %s" % (repr(frame), ))
tb = Traceback(frame)
tb.pretty_print(output=output)
sys.stderr.write("End of stack frame dump\n")
signal.signal(signal_number, dump_frames_on)
signal.signal(signal_number, lambda sig_no, stack_frame: dump_frames_on(sig_no, stack_frame, output))
......@@ -4,12 +4,10 @@ import unittest
import os
import signal
import sys
from satella.instrumentation import install_dump_frames_on
from satella.instrumentation.dump_frames_on import dump_frames_on
logger = logging.getLogger(__name__)
class TestDumpFramesOn(unittest.TestCase):
@unittest.skipIf('win' in sys.platform, 'Running on Windows')
def test_dump_frames_on(self):
install_dump_frames_on(signal.SIGUSR2)
os.kill(0, int(signal.SIGUSR2))
dump_frames_on(0, None, sys.stderr)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment