Skip to content

Commit ac0cc8a

Browse files
add tests to verify newline and strip behavior (#3)
1 parent ebacdbc commit ac0cc8a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/test_shell.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,42 @@ async def test_execute_async():
200200

201201
assert isinstance(result, ExpressionResult)
202202
assert result.value == 4
203+
204+
205+
def test_trailing_newlines_with_expression(shell):
206+
code = """
207+
x = 5
208+
y = 10
209+
x + y
210+
211+
212+
"""
213+
result = shell._execute(code)
214+
215+
assert isinstance(result, ExpressionResult)
216+
assert result.value == 15
217+
assert "15" in result.output
218+
219+
220+
def test_trailing_whitespace_with_expression(shell):
221+
code = "2 + 2 \n\n "
222+
result = shell._execute(code)
223+
224+
assert isinstance(result, ExpressionResult)
225+
assert result.value == 4
226+
227+
228+
def test_leading_newlines_with_expression(shell):
229+
code = "\n\n\n2 + 2"
230+
result = shell._execute(code)
231+
232+
assert isinstance(result, ExpressionResult)
233+
assert result.value == 4
234+
235+
236+
def test_expression_with_trailing_newlines(shell):
237+
code = "x = 5\nx + 10\n\n"
238+
result = shell._execute(code)
239+
240+
assert isinstance(result, ExpressionResult)
241+
assert result.value == 15

0 commit comments

Comments
 (0)