Spaces:
Runtime error
Runtime error
File size: 847 Bytes
c87c295 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import pytest
from evalplus.sanitize import sanitize
def test_inline_fn():
assert (
sanitize(
"""\
def f(n):
def factorial(i):
if i == 0:
return 1
else:
return i * factorial(i-1)
result = []
for i in range(1, n+1):
if i % 2 == 0:
result.append(factorial(i))
else:
result.append(sum(range(1, i+1)))
return result
# Test the function
print(f(5))""",
entry_point="f",
)
== """\
def f(n):
def factorial(i):
if i == 0:
return 1
else:
return i * factorial(i-1)
result = []
for i in range(1, n+1):
if i % 2 == 0:
result.append(factorial(i))
else:
result.append(sum(range(1, i+1)))
return result"""
)
|