Opened 10 years ago
Closed 9 years ago
#23943 closed Cleanup/optimization (fixed)
Audit tests decorated with unittest.expectedFailure
Reported by: | Tim Graham | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | diegaogs@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There are less than 10 tests in our test suite that use @unittest.expectedFailure
. We should check to make sure these tests are still valid.
- Does the test still fail? If not, remove the decorator.
- Is there a plan/ticket to fix the issue? If so, add a comment with the ticket number with the and make sure the test is linked to in the ticket. If not, create a ticket for the issue.
Change History (4)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Cc: | added |
---|
While crossing references on those tests with the @expectedFailure decorator, this one seems that do not pass the audit tests/generic_views/test_edit.py
:
@expectedFailure def test_update_put(self): a = Author.objects.create( name='Randall Munroe', slug='randall-munroe', ) res = self.client.get('/edit/author/%d/update/' % a.pk) self.assertEqual(res.status_code, 200) self.assertTemplateUsed(res, 'generic_views/author_form.html') res = self.client.put('/edit/author/%d/update/' % a.pk, {'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'}) # Here is the expected failure. PUT data are not processed in any special # way by django. So the request will equal to a POST without data, hence # the form will be invalid and redisplayed with errors (status code 200). # See also #12635 self.assertEqual(res.status_code, 302) self.assertRedirects(res, 'http://testserver/list/authors/') self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>'])
This test is related to ticket #12635 marked as wontfix, and according to the last comment on that, Using PUT and DELETE as HTTP methods for the form element is no longer supported (http://www.w3.org/TR/2010/WD-html5-diff-20101019/#changes-2010-06-24).
comment:4 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
1 is a moot point - an expected failure test is run, and is reported as an "unexpected success" if it passes. In python 3.4 at least I think this is considered the same as a fail.
I have used expected failure a few times in the postgres array tests where I expect a query to fail with a database error. If this starts passing, I'd like to know about it and update the documentation. I could catch and inspect the error instead, but I feel saying "run this and I expect it to fail" is better than "run this and expect a given error from outside our code" - I'd use
assertRaises
to check my ownraise
statements only.I don't mind if this is changed (or at least more clearly commented).