2010-09-13 13:28:38 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-06-08 00:08:47 +08:00
|
|
|
from __future__ import absolute_import, unicode_literals
|
2011-10-14 02:04:12 +08:00
|
|
|
|
2010-09-13 13:28:38 +08:00
|
|
|
import datetime
|
|
|
|
|
|
|
|
from django.test import TestCase
|
|
|
|
|
2011-10-14 02:04:12 +08:00
|
|
|
from .models import Article, InternationalArticle
|
|
|
|
|
2010-09-13 13:28:38 +08:00
|
|
|
|
|
|
|
class SimpleTests(TestCase):
|
|
|
|
def test_basic(self):
|
|
|
|
a = Article.objects.create(
|
2012-05-19 23:43:34 +08:00
|
|
|
headline=b'Area man programs in Python',
|
2010-09-13 13:28:38 +08:00
|
|
|
pub_date=datetime.datetime(2005, 7, 28)
|
|
|
|
)
|
2012-05-19 23:43:34 +08:00
|
|
|
self.assertEqual(str(a), b'Area man programs in Python')
|
|
|
|
self.assertEqual(repr(a), b'<Article: Area man programs in Python>')
|
2010-09-13 13:28:38 +08:00
|
|
|
|
|
|
|
def test_international(self):
|
|
|
|
a = InternationalArticle.objects.create(
|
2012-06-08 00:08:47 +08:00
|
|
|
headline='Girl wins €12.500 in lottery',
|
2010-09-13 13:28:38 +08:00
|
|
|
pub_date=datetime.datetime(2005, 7, 28)
|
|
|
|
)
|
|
|
|
# The default str() output will be the UTF-8 encoded output of __unicode__().
|
2012-05-19 23:43:34 +08:00
|
|
|
self.assertEqual(str(a), b'Girl wins \xe2\x82\xac12.500 in lottery')
|