mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-01-23 10:15:11 +00:00
Add test for exception
This commit is contained in:
parent
f6001ce3b1
commit
dea100b929
2 changed files with 54 additions and 0 deletions
49
tests/samples/exception.py
Normal file
49
tests/samples/exception.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import pysnooper
|
||||
|
||||
|
||||
def foo():
|
||||
raise TypeError('bad')
|
||||
|
||||
|
||||
def bar():
|
||||
try:
|
||||
foo()
|
||||
except Exception as e:
|
||||
str(e)
|
||||
raise
|
||||
|
||||
|
||||
@pysnooper.snoop(depth=3)
|
||||
def main():
|
||||
try:
|
||||
bar()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
expected_output = '''
|
||||
12:18:08.017782 call 17 def main():
|
||||
12:18:08.018142 line 18 try:
|
||||
12:18:08.018181 line 19 bar()
|
||||
12:18:08.018223 call 8 def bar():
|
||||
12:18:08.018260 line 9 try:
|
||||
12:18:08.018293 line 10 foo()
|
||||
12:18:08.018329 call 4 def foo():
|
||||
12:18:08.018364 line 5 raise TypeError('bad')
|
||||
12:18:08.018396 exception 5 raise TypeError('bad')
|
||||
TypeError: bad
|
||||
Call ended by exception
|
||||
12:18:08.018494 exception 10 foo()
|
||||
TypeError: bad
|
||||
12:18:08.018545 line 11 except Exception as e:
|
||||
New var:....... e = TypeError('bad',)
|
||||
12:18:08.018597 line 12 str(e)
|
||||
12:18:08.018655 line 13 raise
|
||||
Call ended by exception
|
||||
12:18:08.018718 exception 19 bar()
|
||||
TypeError: bad
|
||||
12:18:08.018761 line 20 except:
|
||||
12:18:08.018787 line 21 pass
|
||||
12:18:08.018813 return 21 pass
|
||||
Return value:.. None
|
||||
'''
|
||||
Loading…
Add table
Add a link
Reference in a new issue