Opened 11 years ago

Closed 11 years ago

#20918 closed Cleanup/optimization (fixed)

Tidy up implementation of custom assertions

Reported by: Marc Tamlyn Owned by: nobody
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The custom assertions provided by Django have a significant amount of duplication between the true and false cases - e.g. between assertContains and assertNotContains. There appear to be subtle difference and it concerns me that perhaps some of these are bugfixes which have only been applied to one of the methods.

For example, assertNotContains seems to not handle streaming responses.

Change History (3)

comment:1 by Tim Graham, 11 years ago

Triage Stage: UnreviewedAccepted

comment:2 by ersran9, 11 years ago

I've written an initial patch https://github.com/django/django/pull/1507 . I'm not really sure if this is the way to go forward. If it is, then I'll move forward with other functions that has the same problem.

comment:3 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In a2374bcf476b49441793f1ad213126b07543da54:

Fixed #20918 -- Tidied up implementation of custom assertions

  1. Moved common logic between assertContains and assertNotContains into a separate function _assert_contains()
  1. Moved common logic between assertTemplateUsed and assertTemplateNotUsed into a separate function _assert_templateused()

Thanks Marc Tamlyn for the report and review.

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