我試圖爲我的程序運行py.test cov,但我仍然有一個信息:testFile.txt sCoverage.py warning: No data was collected.
即使在代碼中仍然是未經過測試的函數(在我的示例函數差異)。以下是我測試命令py.test --cov=testcov.py
的代碼示例。我正在使用python 2.7.9
Pytest cov不會生成任何報告
def suma(x,y):
z = x + y
return z
def diff(x,y):
return x-y
if __name__ == "__main__":
a = suma(2,3)
b = diff(7,5)
print a
print b
## ------------------------TESTS-----------------------------
import pytest
def testSuma():
assert suma(2,3) == 5
有人可以解釋我,我做錯了什麼?