Python 使用 @unittest.expectedFailure 为单元测试提高 _ExpectedFailure [英] Python raising _ExpectedFailure for unittests with @unittest.expectedFailure

查看:18
本文介绍了Python 使用 @unittest.expectedFailure 为单元测试提高 _ExpectedFailure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个系统运行相同的 Django 单元测试集.一些测试使用 @unittest.expectedFailure 装饰器.

I have two systems running the same set of Django unittests. Some of the tests use the @unittest.expectedFailure decorator.

在一个系统上,这些运行良好并在测试运行结束时报告OK(预期失败=10,意外成功=2).

On one system, these are running fine and reporting at the end of the test run OK (expected failures=10, unexpected successes=2).

在另一个系统上,同样的测试错误,但在没有回溯的情况下引发 _ExpectedFailure_UnexpectedSuccess.

On the other system, the same tests error, but raise _ExpectedFailure and _UnexpectedSuccess without tracebacks.

以前有人见过这种行为吗?是配置问题吗?两个系统都运行 Python 2.7、Django 1.3,并安装了 unittest 和 unittest2.

Has anyone seen this behavior before? Is it a configuration issue? Both systems are running Python 2.7, Django 1.3, and have unittest and unittest2 installed.

推荐答案

我遇到了问题,我通过删除/usr/local/lib/python2.7 然后从头开始重新安装所有内容来解决问题.

I have the problem and I got it to work by deleting the /usr/local/lib/python2.7 and then reinstalling everything from scratch.

我认为这样做的原因是python可能没有从它的工作目录中清除它的python对象和缓存文件(*.pyc,*.pyo).也就是说,不是你的项目目录,而是 python 实际运行的目录.

The reason for this I believe is that python may not have cleared it's python object and cache files(*.pyc, *.pyo) from it's working directory. That is, not YOUR project's directory but where python actually runs from.

不确定是不是这样,但它对我有用!!

Not sure if that's it but it worked for me!!

这篇关于Python 使用 @unittest.expectedFailure 为单元测试提高 _ExpectedFailure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆