/tests/modeltests/str/tests.py

https://code.google.com/p/mango-py/ · Python · 23 lines · 17 code · 4 blank · 2 comment · 0 complexity · 1d436557063bda7b62a416ab51330817 MD5 · raw file

  1. # -*- coding: utf-8 -*-
  2. import datetime
  3. from django.test import TestCase
  4. from models import Article, InternationalArticle
  5. class SimpleTests(TestCase):
  6. def test_basic(self):
  7. a = Article.objects.create(
  8. headline='Area man programs in Python',
  9. pub_date=datetime.datetime(2005, 7, 28)
  10. )
  11. self.assertEqual(str(a), 'Area man programs in Python')
  12. self.assertEqual(repr(a), '<Article: Area man programs in Python>')
  13. def test_international(self):
  14. a = InternationalArticle.objects.create(
  15. headline=u'Girl wins â&#x201A;?12.500 in lottery',
  16. pub_date=datetime.datetime(2005, 7, 28)
  17. )
  18. # The default str() output will be the UTF-8 encoded output of __unicode__().
  19. self.assertEqual(str(a), 'Girl wins \xe2\x82\xac12.500 in lottery')