#7878: unicode strings in model doctest silently prevent the test from being run
------------------------------+---------------------------------------------
 Reporter:  davenaff          |       Owner:  nobody    
   Status:  new               |   Milestone:            
Component:  Unit test system  |     Version:  SVN       
 Keywords:                    |       Stage:  Unreviewed
Has_patch:  0                 |  
------------------------------+---------------------------------------------
 Here is the model that I created to demonstrate the bug.  If you create a
 new project with a new models.py file that looks like model file below,
 and try to run the test runner: python manage.py test

 You'll see that 0 tests are run.  If you remove the last line from the
 doctest and rerun the same command, the test runs and fails.


 {{{
 from django.db import models

 class PublicationManager(models.Manager):

     def get_printable_titles(self):
         titles = map(lambda x: x.title, self.all())
         printable_titles = '\n'.join(titles)
         return printable_titles

 class Publication(models.Model):
     """
     # Create a couple of Publications.
     >>> p1 = Publication(id=None, title='The Python Journal')
     >>> p1.save()
     >>> p2 = Publication(id=None, title='Science News')
     >>> p2.save()
     >>> p3 = Publication(id=None, title='Science Weekly')
     >>> p3.save()
     >>> Publication.objects.get_printable_titles()
     u'The Python Journal\nScience News\nScience Weekly'
     """
     title = models.CharField(max_length=30)
     objects = PublicationManager()
 }}}

 This problem can be corrected by making the docstring a raw docstring
 (preceding the string with an 'r').  However, the current 'silently fail
 to run the test' creates a dangerous scenario where users are unlikely to
 know that their tests aren't being run.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7878>
Django Code <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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to