mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
fix unit test fail
This commit is contained in:
parent
3e9f1699ee
commit
b48b56fbe6
3 changed files with 10 additions and 7 deletions
|
|
@ -134,10 +134,11 @@ public class PythonInterpreter extends Interpreter {
|
|||
|
||||
InterpreterResult result;
|
||||
if (pythonErrorIn(output)) {
|
||||
result = new InterpreterResult(Code.ERROR, output.replaceAll(">>> ", "").trim());
|
||||
result = new InterpreterResult(Code.ERROR, output);
|
||||
} else {
|
||||
result = new InterpreterResult(Code.SUCCESS, output.replaceAll(">>> ", "")
|
||||
.replaceAll("\\.\\.\\.", "").trim());
|
||||
// TODO(zjffdu), we should not do string replacement operation in the result, as it is
|
||||
// possible that the output contains the kind of pattern itself, e.g. print("...")
|
||||
result = new InterpreterResult(Code.SUCCESS, output.replaceAll("\\.\\.\\.", ""));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ def intHandler(signum, frame): # Set the signal handler
|
|||
raise KeyboardInterrupt()
|
||||
|
||||
signal.signal(signal.SIGINT, intHandler)
|
||||
# set prompt as empty string so that java side don't need to remove the prompt.
|
||||
sys.ps1=""
|
||||
|
||||
def help():
|
||||
print("""%html
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class PythonInterpreterTest {
|
|||
*/
|
||||
@Test
|
||||
public void testPy4jInstalled() throws IOException, InterruptedException {
|
||||
when(mockPythonProcess.sendAndGetResult(eq("\n\nimport py4j\n"))).thenReturn(">>>");
|
||||
when(mockPythonProcess.sendAndGetResult(eq("\n\nimport py4j\n"))).thenReturn("");
|
||||
|
||||
pythonInterpreter.open();
|
||||
Integer py4jPort = pythonInterpreter.getPy4jPort();
|
||||
|
|
@ -137,7 +137,7 @@ public class PythonInterpreterTest {
|
|||
@Test
|
||||
public void testClose() throws IOException, InterruptedException {
|
||||
//given: py4j is installed
|
||||
when(mockPythonProcess.sendAndGetResult(eq("\n\nimport py4j\n"))).thenReturn(">>>");
|
||||
when(mockPythonProcess.sendAndGetResult(eq("\n\nimport py4j\n"))).thenReturn("");
|
||||
|
||||
pythonInterpreter.open();
|
||||
Integer py4jPort = pythonInterpreter.getPy4jPort();
|
||||
|
|
@ -210,11 +210,11 @@ public class PythonInterpreterTest {
|
|||
String output = "";
|
||||
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
output += ">>>" + lines[i];
|
||||
output += lines[i];
|
||||
}
|
||||
return output;
|
||||
} else {
|
||||
return ">>>";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue