[Django] #28224: Test suite exception catching is not always specific

5 views
Skip to first unread message

Django

unread,
May 19, 2017, 11:35:48 AM5/19/17
to django-...@googlegroups.com
#28224: Test suite exception catching is not always specific
-------------------------------------+-------------------------------------
Reporter: Mads | Owner: nobody
Jensen |
Type: | Status: new
Cleanup/optimization |
Component: Core | Version: master
(Other) |
Severity: Normal | Keywords: exception classes
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
`tests/requests/tests.py` contains some less specific tests. Actually,
it's `DisallowedHost` that's being raised instead for all of these cases.
Isn't it better in general to test for the actual exception class?
Probably there are other cases of tests like this that could be made more
specific.

{{{
with self.assertRaises(SuspiciousOperation):
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28224>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 19, 2017, 1:14:41 PM5/19/17
to django-...@googlegroups.com
#28224: Use more specific exception testing in Django's tests
--------------------------------------+------------------------------------
Reporter: Mads Jensen | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: exception classes | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28224#comment:1>

Django

unread,
May 24, 2017, 3:20:44 PM5/24/17
to django-...@googlegroups.com
#28224: Use more specific exception testing in Django's tests
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Rajesh
Type: | Veeranki
Cleanup/optimization | Status: assigned

Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: exception classes | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Rajesh Veeranki):

* owner: nobody => Rajesh Veeranki
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28224#comment:2>

Django

unread,
May 24, 2017, 3:45:28 PM5/24/17
to django-...@googlegroups.com
#28224: Use more specific exception testing in Django's tests
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Rajesh
Type: | Veeranki
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: exception classes | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Rajesh Veeranki):

* has_patch: 0 => 1


Comment:

Please review the PR here: https://github.com/django/django/pull/8545
I have searched the tests for any instances of `SuspiciousOperation` and
replaced with appropriate derived exception

--
Ticket URL: <https://code.djangoproject.com/ticket/28224#comment:3>

Django

unread,
May 25, 2017, 8:18:18 AM5/25/17
to django-...@googlegroups.com
#28224: Test for SuspiciousOperation subclasses rather than SuspiciousOperation in

Django's tests
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Rajesh
Type: | Veeranki
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: exception classes | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/28224#comment:4>

Django

unread,
May 25, 2017, 8:19:26 AM5/25/17
to django-...@googlegroups.com
#28224: Test for SuspiciousOperation subclasses rather than SuspiciousOperation in
Django's tests
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: Rajesh
Type: | Veeranki
Cleanup/optimization | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed

Keywords: exception classes | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"67e1afb4a8478af6725e45a9fdcd2a511b2eb005" 67e1afb4]:
{{{
#!CommitTicketReference repository=""
revision="67e1afb4a8478af6725e45a9fdcd2a511b2eb005"
Fixed #28224 -- Tested for SuspiciousOperation subclasses in Django's
tests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28224#comment:5>

Reply all
Reply to author
Forward
0 new messages