psychopath94 2018-09-30 08:19 采纳率: 0%
浏览 3491

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批处理命令执行,这样进程是停滞的,也结束不了。

  • 写回答

3条回答 默认 最新

  • lyhsdy 2018-10-07 03:54
    关注

    楼主放错代码了吧,错误的是line57,in addTests
    for test in tests:
    但是代码没有这句

    评论

报告相同问题?

悬赏问题

  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。