我有一个具有以下结构的项目
test_scripts.py由单个unittest.TestCase类组成,并以以下代码结尾。
if __name__ == '__main__':
try:
from teamcity import is_running_under_teamcity
from teamcity.unittestpy import TeamcityTestRunner
if is_running_under_teamcity():
runner = TeamcityTestRunner()
else:
runner = unittest.TextTestRunner()
except ModuleNotFoundError:
runner = unittest.TextTestRunner()
unittest.main(testRunner=runner)
所以当我尝试用 python3 运行它时,
python3 -m teamcity.unittestpy我得到了
... some tests output
##teamcity[testFinished timestamp='2019-11-14T14:08:24.591' duration='0' flowId='tests.test_scripts.Test.test_sub' name='tests.test_scripts.Test.test_sub']
Ran 7 tests in 0.004s
OK
但是当我对 Python 2 做同样的事情时
python -m teamcity.unittestpy
##teamcity[testCount timestamp='2019-11-14T14:09:16.392' count='0']
Ran 0 tests in 0.000s
OK
我 100% 确定它teamcity-messages安装在python解释器上。为什么它看不到测试?
