#10314: TestCase assert methods do not accept a msg parameter
----------------------------------------+-----------------------------------
          Reporter:  wwinham            |         Owner:  nobody
            Status:  reopened           |     Milestone:        
         Component:  Testing framework  |       Version:  1.0   
        Resolution:                     |      Keywords:        
             Stage:  Accepted           |     Has_patch:  0     
        Needs_docs:  0                  |   Needs_tests:  0     
Needs_better_patch:  0                  |  
----------------------------------------+-----------------------------------
Changes (by christian.oud...@gmail.com):

  * status:  closed => reopened
  * resolution:  invalid =>

Comment:

 Attached a patch which adds msg parameters to all django test case assert*
 functions.

 I didn't understand at first what you meant by having more than one
 exception raised, but now that I got into the code, I do. There are
 multiple ways that each assert method can fail. For example, in
 `assertContains`, it could have the wrong status code, not contain the
 text, or not contain the text the correct number of times. Each of these
 three outcomes has a different default message.

 However, I believe that there are cases where each of the default messages
 is inadequate. Take for example, a test that looks through pages for
 invalid template variables:

 {{{
 class TemplateTestCase(ClientTestCase):
     def testTemplateError(self):
         urls = [
             '/',
             '/home/',
             '/admin/',
             # etcetera ...
         ]
         for url in urls:
             response = self.client.get(url, follow=True)
             self.assertNotContains(
                 response,
                 settings.TEMPLATE_STRING_IF_INVALID,
                 msg='Found an invalid variable in url %s' % url)
 }}}

 Without the message parameter, it would require print statements to
 determine which url actually failed.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10314#comment:3>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to