Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
5733bac2
Commit
5733bac2
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
smarter tests
parent
8bea0041
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
satella/instrumentation/dump_frames_on.py
+11
-9
11 additions, 9 deletions
satella/instrumentation/dump_frames_on.py
tests/test_exception_handling/test_dump_frames_on.py
+2
-4
2 additions, 4 deletions
tests/test_exception_handling/test_dump_frames_on.py
with
13 additions
and
13 deletions
satella/instrumentation/dump_frames_on.py
+
11
−
9
View file @
5733bac2
...
...
@@ -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
))
This diff is collapsed.
Click to expand it.
tests/test_exception_handling/test_dump_frames_on.py
+
2
−
4
View file @
5733bac2
...
...
@@ -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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment