expectedFailure被视为错误而不是通过 [英] expectedFailure is being counted as an error instead of as passed

查看:426
本文介绍了expectedFailure被视为错误而不是通过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 expectedFailure ,因为有一个我想要记录的错误,我现在无法修复,但希望以后再回来。我对 expectedFailure 的理解是,它会将测试计算为已通过,但在总结中表示有x个预期的失败(类似于它与跳过的tets的工作原理)。

I'm using expectedFailure because there is a bug that I want to record that I can't fix right now, but want to come back to it in the future. My understanding of expectedFailure is that it would count the test as passed but in the summary say that there were x number of expected failures (similar to how it works with skipped tets).

但是,当我运行测试套件时,我得到以下内容:

However, when I run my test suite I get the following:

$ ./manage.py test eav.QueryTest
Creating test database for alias 'default'...
.EE
======================================================================
ERROR: test_q_object_with_exclude (eav.tests.managers.QueryTest)
----------------------------------------------------------------------
_ExpectedFailure

======================================================================
ERROR: test_q_objects_unioned (eav.tests.managers.QueryTest)
----------------------------------------------------------------------
_ExpectedFailure

----------------------------------------------------------------------
Ran 3 tests in 1.095s

FAILED (errors=2)
Destroying test database for alias 'default'...

我不知道这是否与Django的测试运行员或我正在做的事情

I'm not sure if this lies with Django's test runner or something I'm doing wrong.

@unittest.expectedFailure
def test_q_object_with_exclude(self):
    # Everyone except Bob
    q_set = eav_m.Process.objects.exclude(
        Q(eav__details__city__contains='Y'))
    self.assertEqual(q_set.count(), 4)


推荐答案

您对 expectedFailure 的理解是正确的。你的问题是那些测试不会失败,他们会引发与失败不同的异常。

Your understanding of expectedFailureis right. Your problem is that those tests don't fail they raise an exception which is not the same as failing.

您正在寻找的装饰器是跳过

The decorator you are looking for is skip.

这篇关于expectedFailure被视为错误而不是通过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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