python - 在 try 中的 Nose 测试中手动添加错误 - except

标签 python nose

我的问题是在 Nose 测试的帮助下运行测试。当我使用 try-except 并且出现错误时,nosetests 显示点字符,这意味着它已经成功。您可以在 except 中设置一个选项来强制使用 F 或 E 字符吗?你遇到过这样的问题吗? 例如 54 次测试(7 次失败),但我全部正确。

.....................................................................
----------------------------------------------------------------------
Ran 54 tests in 724.380s

OK

最佳答案

如果你尝试并排除一个错误,你实际上是在声明有错误没关系,所以

  1. 删除您的尝试,除非

OR

  • 在 except 子句中放入 raise 语句...这将引发最后一个错误
  • short example

    try:
        assert False
    except AssertionError as intended_exception:
        print(intended_exception)
        raise
    

    关于python - 在 try 中的 Nose 测试中手动添加错误 - except,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56792661/

    相关文章:

    python - 导入模块前的 nose-doctest 模块夹具

    python - 与 Python 相比,在 Haskell 中调用 c 函数

    python - 本地测试 GAE-python27-django 项目

    python - nose2 与 py.test 隔离进程

    用 Nose : Making sequential tests 进行 Python 单元测试

    python - 测试 IPython 笔记本

    python - Redis 中的字典列表

    python - 使用 T5 的句子嵌入

    Python zipfile 不释放 zip 文件

    python - 每个 View 更改数据库并访问每个 View 的多个数据库