Skip to content

Commit

Permalink
Make traceback a getter
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Apr 4, 2024
1 parent fefabf8 commit 5cec3e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/src/messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ExecutionError {
/**
* Returns the traceback of the error as a string.
*/
traceback(): string {
get traceback(): string {
return this.tracebackRaw.join('\n')
}
}
Expand Down
7 changes: 5 additions & 2 deletions python/tests/test_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
def test_streaming_output():
out = []
with CodeInterpreter() as sandbox:

def test(line) -> int:
out.append(line)
return 1

sandbox.notebook.exec_cell("print(1)", on_stdout=test)

assert len(out) == 1
Expand All @@ -16,7 +18,9 @@ def test(line) -> int:
def test_streaming_error():
out = []
with CodeInterpreter() as sandbox:
sandbox.notebook.exec_cell("import sys;print(1, file=sys.stderr)", on_stderr=out.append)
sandbox.notebook.exec_cell(
"import sys;print(1, file=sys.stderr)", on_stderr=out.append
)

assert len(out) == 1
assert out[0].line == "1\n"
Expand All @@ -41,4 +45,3 @@ def test_streaming_result():
sandbox.notebook.exec_cell(code, on_result=out.append)

assert len(out) == 2

0 comments on commit 5cec3e1

Please sign in to comment.