make z.getInterpreterContext().out().clear() work in IPythonInterprete

This commit is contained in:
Lee moon soo 2018-03-02 17:42:41 -08:00
parent 224a2df8e6
commit e0dcda61fa
2 changed files with 8 additions and 0 deletions

View file

@ -33,6 +33,9 @@ class PyZeppelinContext(object):
self.javaList = gateway.jvm.java.util.ArrayList
self.max_result = z.getMaxResult()
def getInterpreterContext(self):
return self.z.getInterpreterContext()
def input(self, name, defaultValue=""):
return self.z.input(name, defaultValue)

View file

@ -456,6 +456,11 @@ public class IPythonInterpreterTest {
interpreterResultMessages = context.out.getInterpreterResultMessages();
assertEquals(InterpreterResult.Type.TABLE, interpreterResultMessages.get(0).getType());
assertEquals("id\tname\n1\ta\n2\tb\n3\tc\n", interpreterResultMessages.get(0).getData());
// clear output
context = getInterpreterContext();
result = interpreter.interpret("import time\nprint(\"Hello\")\ntime.sleep(0.5)\nz.getInterpreterContext().out().clear()\nprint(\"world\")\n", context);
assertEquals("%text world\n", context.out.getCurrentOutput().toString());
}
private static InterpreterContext getInterpreterContext() {