diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-16 09:44:00 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-16 09:44:42 +0200 |
| commit | e98cb05edf87eebf939a680066822c16f1257f44 (patch) | |
| tree | 511fbb078d01e92f31daf0c150a3af4ed60ead4e | |
| parent | 71d07fb048849db5a0a3b1d81f87fae51c6097c0 (diff) | |
[py3] Fixed the str tests.
These tests don't look very meaningful. They were ported from
doctests...
| -rw-r--r-- | tests/modeltests/str/tests.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/modeltests/str/tests.py b/tests/modeltests/str/tests.py index bed9ea719b..2c11ac8c78 100644 --- a/tests/modeltests/str/tests.py +++ b/tests/modeltests/str/tests.py @@ -4,23 +4,32 @@ from __future__ import absolute_import, unicode_literals import datetime from django.test import TestCase +from django.utils import six +from django.utils.unittest import skipIf from .models import Article, InternationalArticle class SimpleTests(TestCase): + + @skipIf(six.PY3, "tests a __str__ method returning unicode under Python 2") def test_basic(self): a = Article.objects.create( headline=b'Area man programs in Python', pub_date=datetime.datetime(2005, 7, 28) ) - self.assertEqual(str(a), b'Area man programs in Python') - self.assertEqual(repr(a), b'<Article: Area man programs in Python>') + self.assertEqual(str(a), str('Area man programs in Python')) + self.assertEqual(repr(a), str('<Article: Area man programs in Python>')) def test_international(self): a = InternationalArticle.objects.create( headline='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), b'Girl wins \xe2\x82\xac12.500 in lottery') + if six.PY3: + self.assertEqual(str(a), 'Girl wins €12.500 in lottery') + else: + # On Python 2, the default str() output will be the UTF-8 encoded + # output of __unicode__() -- or __str__() when the + # python_2_unicode_compatible decorator is used. + self.assertEqual(str(a), b'Girl wins \xe2\x82\xac12.500 in lottery') |
