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)
Your understanding of expectedFailure
is 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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With