mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-01-23 10:15:11 +00:00
Add test-case for multiline decorator and lambda
This commit is contained in:
parent
016f4b9976
commit
8665a46ced
1 changed files with 32 additions and 0 deletions
|
|
@ -197,3 +197,35 @@ def test_file_output():
|
|||
)
|
||||
)
|
||||
|
||||
def test_function_name_finding():
|
||||
string_io = io.StringIO()
|
||||
@pysnooper.snoop(string_io,
|
||||
depth = 2
|
||||
# Multiline decorator
|
||||
)
|
||||
def my_function(foo):
|
||||
x = lambda bar: 7
|
||||
y = 8
|
||||
return y + x(foo)
|
||||
result = my_function('baba')
|
||||
assert result == 15
|
||||
output = string_io.getvalue()
|
||||
assert_output(
|
||||
output,
|
||||
(
|
||||
VariableEntry('foo', value_regex="u?'baba'"),
|
||||
CallEntry('def my_function(foo):'),
|
||||
LineEntry(),
|
||||
VariableEntry(),
|
||||
LineEntry(),
|
||||
VariableEntry(),
|
||||
LineEntry(),
|
||||
# inside lambda
|
||||
VariableEntry('bar', value_regex="u?'baba'"),
|
||||
CallEntry('x = lambda bar: 7'),
|
||||
LineEntry(),
|
||||
ReturnEntry(),
|
||||
# back in my_function
|
||||
ReturnEntry(),
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue