trace_commentor/tests/test_definitions.py
2024-04-19 18:51:21 +08:00

37 lines
559 B
Python

from test_utils import *
def test_function_def():
@Commentor("<return>")
def target():
pass
asserteq_or_print(target(), '''
def target():
pass
''')
def test_return():
with closing(StringIO()) as f:
@Commentor(f)
def target():
a = 1
return a + 1
assert target() == 2
asserteq_or_print(
f.getvalue(), '''
def target():
a = 1
return a + 1
"""
1 : a
2 : a + 1
"""
''')