diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-09-13 05:28:38 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-09-13 05:28:38 +0000 |
| commit | 2055fdbe97ab421c2a732f450e76bcc5b84aa62a (patch) | |
| tree | 9a03db149269cbd756adcdbd3870d5ce7c07e41a | |
| parent | 6948b280c77bea23df3d3471f454065b0d7be5ab (diff) | |
Migrated str doctests. Thanks to Eric Florenzano.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13827 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | tests/modeltests/str/models.py | 21 | ||||
| -rw-r--r-- | tests/modeltests/str/tests.py | 23 |
2 files changed, 24 insertions, 20 deletions
diff --git a/tests/modeltests/str/models.py b/tests/modeltests/str/models.py index 644c6025ab..84b8d67d12 100644 --- a/tests/modeltests/str/models.py +++ b/tests/modeltests/str/models.py @@ -30,23 +30,4 @@ class InternationalArticle(models.Model): 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 diff --git a/tests/modeltests/str/tests.py b/tests/modeltests/str/tests.py new file mode 100644 index 0000000000..4e4c76501f --- /dev/null +++ b/tests/modeltests/str/tests.py @@ -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 |
