直接运行时if __name__ == '__main__': 后面的代码不会被执行。 一个比较有用的答案 解决办法: 右键run as 选择python run 而不是python unit-test(此项为默认选项)