#28224 closed Cleanup/optimization (fixed)

Test for SuspiciousOperation subclasses rather than SuspiciousOperation in Django's tests

Reported by: Mads Jensen Owned by: Rajesh Veeranki
Component: Core (Other) Version: master
Severity: Normal Keywords: exception classes
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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):

Change History (5)

comment:1 Changed 21 months ago by Tim Graham

Summary: Test suite exception catching is not always specificUse more specific exception testing in Django's tests
Triage Stage: UnreviewedAccepted

comment:2 Changed 21 months ago by Rajesh Veeranki

Owner: changed from nobody to Rajesh Veeranki
Status: newassigned

comment:3 Changed 21 months ago by Rajesh Veeranki

Has patch: set

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

comment:4 Changed 21 months ago by Tim Graham

Summary: Use more specific exception testing in Django's testsTest for SuspiciousOperation subclasses rather than SuspiciousOperation in Django's tests
Triage Stage: AcceptedReady for checkin

comment:5 Changed 21 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 67e1afb4:

Fixed #28224 -- Tested for SuspiciousOperation subclasses in Django's tests.

Note: See TracTickets for help on using tickets.
Back to Top