我在python 3.6中导入了unittest,并像这样使用它:
class TestFunc(unittest.TestCase):
def test_half(self):
pass
def test_merge(self):
pass
def test_decrypt(self):
pass
def test_rank(self):
pass
if __name__ == "__main__":
print("printing before calling unittest")
unittest.main()
print("printing after calling unittest")
输出如下:
printing before calling unittest
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s
OK
Process finished with exit code 0
和print
的第二次调用,即print("printing after calling unittest")
,不会执行。
为什么我在单元测试后无法做任何事情?如何在测试后继续使用代码?