refine run_cell and parse_outputs.

This commit is contained in:
刘棒棒 2024-03-11 17:00:44 +08:00
parent 3c9ed18f7e
commit 09e3a8e1fa
2 changed files with 17 additions and 24 deletions

View file

@ -68,7 +68,7 @@ async def test_run_code_text():
executor = ExecuteNbCode()
message, success = await executor.run(code='print("This is a code!")', language="python")
assert success
assert message == "This is a code!\n"
assert "This is a code!" in message
message, success = await executor.run(code="# This is a code!", language="markdown")
assert success
assert message == "# This is a code!"
@ -118,10 +118,11 @@ async def test_parse_outputs():
import pandas as pd
df = pd.DataFrame({'ID': [1,2,3], 'NAME': ['a', 'b', 'c']})
print(df.columns)
print(f"columns num:{len(df.columns)}")
print(df['DUMMPY_ID'])
"""
output, is_success = await executor.run(code)
assert not is_success
assert "Index(['ID', 'NAME'], dtype='object')" in output
assert "Executed code failed," in output
assert "KeyError: 'DUMMPY_ID'" in output
assert "columns num:2" in output