Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Migrated str doctests. Thanks to Eric Florenzano.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13827 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2055fdbe97ab421c2a732f450e76bcc5b84aa62a 1 parent 6948b28
Russell Keith-Magee freakboy3742 authored
Showing with 24 additions and 20 deletions.
  1. +1 −20 tests/modeltests/str/models.py
  2. +23 −0 tests/modeltests/str/tests.py
21 tests/modeltests/str/models.py
View
@@ -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
23 tests/modeltests/str/tests.py
View
@@ -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')
Please sign in to comment.
Something went wrong with that request. Please try again.