Skip to content

Commit

Permalink
make z.getInterpreterContext().out().clear() work in PythonInterpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
Leemoonsoo committed Mar 3, 2018
1 parent 21dc20d commit 224a2df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Expand Up @@ -388,6 +388,7 @@ public InterpreterResult interpret(String cmd, InterpreterContext contextInterpr

zeppelinContext.setGui(context.getGui());
zeppelinContext.setNoteGui(context.getNoteGui());
zeppelinContext.setInterpreterContext(context);

if (!pythonscriptRunning) {
return new InterpreterResult(Code.ERROR, "python process not running"
Expand Down
2 changes: 1 addition & 1 deletion python/src/main/resources/python/zeppelin_python.py
Expand Up @@ -61,7 +61,7 @@ def __init__(self, z):
self._setup_matplotlib()

def getInterpreterContext(self):
return self.z.getCurrentInterpreterContext()
return self.z.getInterpreterContext()

def input(self, name, defaultValue=""):
return self.z.input(name, defaultValue)
Expand Down
Expand Up @@ -123,6 +123,12 @@ public void testRedefinitionZeppelinContext() throws InterpreterException {
assertEquals(InterpreterResult.Code.SUCCESS, pythonInterpreter.interpret(pyValidCode, context).code());
}

@Test
public void testOutputClear() throws InterpreterException {
InterpreterResult result = pythonInterpreter.interpret("print(\"Hello\")\nz.getInterpreterContext().out().clear()\nprint(\"world\")\n", context);
assertEquals("%text world\n", out.getCurrentOutput().toString());
}

@Override
public void onUpdateAll(InterpreterOutput out) {

Expand Down

0 comments on commit 224a2df

Please sign in to comment.