开发者社区> 问答> 正文

python unittest执行程序在pycharm可以成功运行但使用cmd会报错 ?报错

如题,在pycharm中执行主程序运行成功:

已连接主机
登录成功
正在发送......
邮件发送完成~

Process finished with exit code 0

   在cmd执行主程序报错:

Traceback (most recent call last):
File"all_test.py",line 32,in
alltestnames = creatsuite()
File"all_test.py",line 27,in creatsuite
testunit.addTests(test_case)
File "C:\Python37\lib\unittest\suite.py",line57,in addTests
for test in tests:
TypeError:'_FailedTest'object is not iterable

报错的程序代码是这部分:

def creatsuite():

testunit = unittest.TestSuite()
test_dir = test_suite_dir
package_tests = unittest.defaultTestLoader.discover(test_dir,
                                                    pattern='*.py',
                                                    top_level_dir=None)
for test_suite in package_tests:
    for test_case in test_suite:
        testunit.addTests(test_case)
        print(testunit)
return testunit

刚接触接口测试,请问是哪里出了问题呢?因为正在jenkins构建项目执行,把源码放在github后使用windows批处理命令执行,这样进程是停滞的,也结束不了。

展开
收起
爱吃鱼的程序员 2020-06-23 01:14:46 1291 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    楼主放错代码了吧,错误的是line57,inaddTests
    fortestintests:
    但是代码没有这句

    这个是由于缺少环境变量LD_LIBRARY_PATH
    在终端查一下这个环境变量的值是多少,然后在jenkins上配置一下

    请问你解决问题了吗

    2020-06-23 01:15:02
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载