Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expectedFailure is being counted as an error instead of as passed

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'...

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)
like image 793
Jashugan Avatar asked Dec 13 '11 17:12

Jashugan


1 Answers

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.

like image 192
frog32 Avatar answered Sep 21 '22 06:09

frog32