Author: russellm Date: 2010-09-13 00:47:26 -0500 (Mon, 13 Sep 2010) New Revision: 13836
Added: django/branches/releases/1.2.X/tests/modeltests/str/tests.py Modified: django/branches/releases/1.2.X/tests/modeltests/str/models.py Log: [1.2.X] Migrated str doctests. Thanks to Eric Florenzano. Backport of r13827 from trunk. Modified: django/branches/releases/1.2.X/tests/modeltests/str/models.py =================================================================== --- django/branches/releases/1.2.X/tests/modeltests/str/models.py 2010-09-13 05:47:13 UTC (rev 13835) +++ django/branches/releases/1.2.X/tests/modeltests/str/models.py 2010-09-13 05:47:26 UTC (rev 13836) @@ -30,23 +30,4 @@ pub_date = models.DateTimeField() def __unicode__(self): - return self.headline - -__test__ = {'API_TESTS':ur""" -# Create an Article. ->>> from datetime import datetime ->>> a = Article(headline='Area man programs in Python', pub_date=datetime(2005, 7, 28)) ->>> a.save() - ->>> str(a) -'Area man programs in Python' - ->>> a -<Article: Area man programs in Python> - ->>> a1 = InternationalArticle(headline=u'Girl wins €12.500 in lottery', pub_date=datetime(2005, 7, 28)) - -# The default str() output will be the UTF-8 encoded output of __unicode__(). ->>> str(a1) -'Girl wins \xe2\x82\xac12.500 in lottery' -"""} + return self.headline \ No newline at end of file Added: django/branches/releases/1.2.X/tests/modeltests/str/tests.py =================================================================== --- django/branches/releases/1.2.X/tests/modeltests/str/tests.py (rev 0) +++ django/branches/releases/1.2.X/tests/modeltests/str/tests.py 2010-09-13 05:47:26 UTC (rev 13836) @@ -0,0 +1,23 @@ + # -*- coding: utf-8 -*- +import datetime + +from django.test import TestCase + +from models import Article, InternationalArticle + +class SimpleTests(TestCase): + def test_basic(self): + a = Article.objects.create( + headline='Area man programs in Python', + pub_date=datetime.datetime(2005, 7, 28) + ) + self.assertEqual(str(a), 'Area man programs in Python') + self.assertEqual(repr(a), '<Article: Area man programs in Python>') + + def test_international(self): + a = InternationalArticle.objects.create( + headline=u'Girl wins €12.500 in lottery', + pub_date=datetime.datetime(2005, 7, 28) + ) + # The default str() output will be the UTF-8 encoded output of __unicode__(). + self.assertEqual(str(a), 'Girl wins \xe2\x82\xac12.500 in lottery') \ No newline at end of file -- 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. 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.