Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[py3] Fixed test_utils tests of doctests.

  • Loading branch information...
commit 8c356acf2e6896759e6ca7a369f0b04766a928f3 1 parent 688678e
@aaugustin aaugustin authored
Showing with 19 additions and 14 deletions.
  1. +19 −14 tests/regressiontests/test_utils/tests.py
View
33 tests/regressiontests/test_utils/tests.py
@@ -5,6 +5,7 @@
from django.http import HttpResponse
from django.template.loader import render_to_string
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
+from django.utils import six
from django.utils.unittest import skip
from .models import Person
@@ -495,12 +496,6 @@ class MyCustomField(IntegerField):
>>> from django.utils.xmlutils import SimplerXMLGenerator
>>> from django.utils.six import StringIO
->>> def produce_long():
-... return 42L
-
->>> def produce_int():
-... return 42
-
>>> def produce_json():
... return json.dumps(['foo', {'bar': ('baz', None, 1.0, 2), 'whiz': 42}])
@@ -529,14 +524,6 @@ class MyCustomField(IntegerField):
... xml.endElement("bar")
... return stream.getvalue()
-# Long values are normalized and are comparable to normal integers ...
->>> produce_long()
-42
-
-# ... and vice versa
->>> produce_int()
-42L
-
# JSON output is normalized for field order, so it doesn't matter
# which order json dictionary attributes are listed in output
>>> produce_json()
@@ -560,3 +547,21 @@ class MyCustomField(IntegerField):
'<foo bbb="2.0" aaa="1.0">Hello</foo><bar ddd="4.0" ccc="3.0"></bar>'
"""}
+
+if not six.PY3:
+ __test__["API_TEST"] += """
+>>> def produce_long():
+... return 42L
+
+>>> def produce_int():
+... return 42
+
+# Long values are normalized and are comparable to normal integers ...
+>>> produce_long()
+42
+
+# ... and vice versa
+>>> produce_int()
+42L
+
+"""
Please sign in to comment.
Something went wrong with that request. Please try again.