小编use*_*237的帖子

如何在python中的shell脚本中设置退出状态

我想获得在从python调用的shell脚本中设置的退出状态.代码如下

python脚本.

result = os.system("./compile_cmd.sh")
print result
Run Code Online (Sandbox Code Playgroud)

(compile_cmd.sh)

javac @source.txt
#i do some code here to get the no of compilation errors
if [$error1 -e 0 ]
then
echo "\n********** JAVA compilation sucessfull **********"
exit 0
else
echo "\n** JAVA Compilation Error in file ** File not checked in to CVS **"
exit 1
fi
Run Code Online (Sandbox Code Playgroud)

我正在运行此代码.但无论我返回什么退出状态,我得到的结果var为0(我认为它返回shell脚本是否成功运行)我知道如何获取我在shell脚本中设置的退出状态python脚本??

python unix shell

7
推荐指数
2
解决办法
9996
查看次数

如何在powermock中模拟void方法

如何模拟一个非静态、非final的void方法方法的签名如下。我正在使用 Powermockito。

public class Name{

public void methodName{
...
...
}
}

@RunWith(PowerMockRunner.class)
@PrepareForTest({Name.class})
public class TestClass{
@Test
public void testMethodName(){
PowerMockito.doNothing().when(Name.class, methodName);
//some  when calls after this and assert later on
}
Run Code Online (Sandbox Code Playgroud)

当 methodName 被调用时我不想做任何事情。上面的代码不起作用。它说 methodName 无法解析。

java unit-testing junit4 powermock

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×1

junit4 ×1

powermock ×1

python ×1

shell ×1

unit-testing ×1

unix ×1