#12226: Test HttpResponse template attribute needlessly hard to use
-------------------------------+--------------------------------------------
 Reporter:  carljm             |       Owner:  nobody    
   Status:  new                |   Milestone:            
Component:  Testing framework  |     Version:  1.1       
 Keywords:                     |       Stage:  Unreviewed
Has_patch:  0                  |  
-------------------------------+--------------------------------------------
 The {{{ template }}} attribute of the response objects returned by
 Django's test client might be a single template object or might be a list
 of template objects, depending whether template inheritance was used. If
 one tries to write tests that are usable in the presence of user-
 overridden templates, this results in noisy boilerplate in the tests:

 {{{
 response = client.get('/')
 try:
     template_name = response.template.name
 except AttributeError:
     template_name = response.template[0].name
 }}}

 There's no need for all this: the attribute should simply always be a
 list, sometimes of length 1.

 I would suggest that a new attribute {{{ templates }}} could be added
 which is always a list, and the old attribute {{{ template }}} could go
 through the usual deprecation cycle.

 I'll work on a patch if this approach is accepted in principle.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12226>
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-upda...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=.


Reply via email to