【问题标题】:Teamcity messages unittest doesnt see tests in Python 2Teamcity 消息 unittest 在 Python 2 中看不到测试
【发布时间】:2019-11-14 20:38:42
【问题描述】:

我有一个具有以下结构的项目

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 解释器上。 为什么它看不到测试?

【问题讨论】:

    标签: python unit-testing teamcity


    【解决方案1】:

    在 Python 2 中,它仅适用于 python -m teamcity.unittestpy discover 调用。 此调用也适用于 Python 3。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多