summaryrefslogtreecommitdiff
path: root/parts/django/tests/modeltests/str/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'parts/django/tests/modeltests/str/tests.py')
-rw-r--r--parts/django/tests/modeltests/str/tests.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/parts/django/tests/modeltests/str/tests.py b/parts/django/tests/modeltests/str/tests.py
new file mode 100644
index 0000000..4e4c765
--- /dev/null
+++ b/parts/django/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