首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Teamcity消息单元测试看不到Python 2中的测试

Teamcity消息单元测试看不到Python 2中的测试
EN

Stack Overflow用户
提问于 2019-11-14 19:11:58
回答 1查看 175关注 0票数 1

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

test_scripts.py由单个unittest.TestCase类组成,并以以下代码结束。

代码语言:javascript
复制
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运行它时,我得到

代码语言:javascript
复制
... 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

但是当我用Python2做同样的事情时

代码语言:javascript
复制
python -m teamcity.unittestpy
##teamcity[testCount timestamp='2019-11-14T14:09:16.392' count='0']


Ran 0 tests in 0.000s

OK

我100%确定python解释器上安装了teamcity-messages。为什么它看不到测试?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-14 20:38:43

在Python2中,它只能与python -m teamcity.unittestpy discover调用一起使用。此调用也适用于Python 3。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58855444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档