summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-07-20 12:45:19 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-07-22 09:29:53 +0200
commit56dbe924a6e700cefbfd34f1a5aa6c1ee01478dc (patch)
treedb6519ad2cb48518c61d9b0c74bcc7b2a5b453fa /tests
parentf1d5dc81ac37fe9a7c7ca860900ee6a16150bb09 (diff)
[py3] Removed longs.
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/basic/tests.py22
-rw-r--r--tests/modeltests/field_defaults/tests.py3
-rw-r--r--tests/regressiontests/i18n/tests.py3
-rw-r--r--tests/regressiontests/model_fields/tests.py7
4 files changed, 20 insertions, 15 deletions
diff --git a/tests/modeltests/basic/tests.py b/tests/modeltests/basic/tests.py
index 3f00fb25fe..d96c60bbe8 100644
--- a/tests/modeltests/basic/tests.py
+++ b/tests/modeltests/basic/tests.py
@@ -5,6 +5,7 @@ from datetime import datetime
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.fields import Field, FieldDoesNotExist
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
+from django.utils.six import PY3
from django.utils.translation import ugettext_lazy
from .models import Article
@@ -321,17 +322,18 @@ class ModelTest(TestCase):
["<Article: Area man programs in Python>",
"<Article: Third article>"])
- # Slicing works with longs.
- self.assertEqual(Article.objects.all()[0L], a)
- self.assertQuerysetEqual(Article.objects.all()[1L:3L],
- ["<Article: Second article>", "<Article: Third article>"])
- self.assertQuerysetEqual((s1 | s2 | s3)[::2L],
- ["<Article: Area man programs in Python>",
- "<Article: Third article>"])
+ # Slicing works with longs (Python 2 only -- Python 3 doesn't have longs).
+ if not PY3:
+ self.assertEqual(Article.objects.all()[long(0)], a)
+ self.assertQuerysetEqual(Article.objects.all()[long(1):long(3)],
+ ["<Article: Second article>", "<Article: Third article>"])
+ self.assertQuerysetEqual((s1 | s2 | s3)[::long(2)],
+ ["<Article: Area man programs in Python>",
+ "<Article: Third article>"])
- # And can be mixed with ints.
- self.assertQuerysetEqual(Article.objects.all()[1:3L],
- ["<Article: Second article>", "<Article: Third article>"])
+ # And can be mixed with ints.
+ self.assertQuerysetEqual(Article.objects.all()[1:long(3)],
+ ["<Article: Second article>", "<Article: Third article>"])
# Slices (without step) are lazy:
self.assertQuerysetEqual(Article.objects.all()[0:5].filter(),
diff --git a/tests/modeltests/field_defaults/tests.py b/tests/modeltests/field_defaults/tests.py
index 206d380e1e..5d9b45610e 100644
--- a/tests/modeltests/field_defaults/tests.py
+++ b/tests/modeltests/field_defaults/tests.py
@@ -3,6 +3,7 @@ from __future__ import absolute_import
from datetime import datetime
from django.test import TestCase
+from django.utils import six
from .models import Article
@@ -13,6 +14,6 @@ class DefaultTests(TestCase):
now = datetime.now()
a.save()
- self.assertTrue(isinstance(a.id, (int, long)))
+ self.assertTrue(isinstance(a.id, six.integer_types))
self.assertEqual(a.headline, "Default headline")
self.assertTrue((now - a.pub_date).seconds < 5)
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index f91d7c042b..69260edb0a 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -19,6 +19,7 @@ from django.utils.formats import (get_format, date_format, time_format,
from django.utils.importlib import import_module
from django.utils.numberformat import format as nformat
from django.utils.safestring import mark_safe, SafeString, SafeUnicode
+from django.utils.six import PY3
from django.utils.translation import (ugettext, ugettext_lazy, activate,
deactivate, gettext_lazy, pgettext, npgettext, to_locale,
get_language_info, get_language, get_language_from_request)
@@ -309,7 +310,7 @@ class FormattingTests(TestCase):
self.d = datetime.date(2009, 12, 31)
self.dt = datetime.datetime(2009, 12, 31, 20, 50)
self.t = datetime.time(10, 15, 48)
- self.l = 10000L
+ self.l = 10000 if PY3 else long(10000)
self.ctxt = Context({
'n': self.n,
't': self.t,
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
index b94c4696f9..e86159463d 100644
--- a/tests/regressiontests/model_fields/tests.py
+++ b/tests/regressiontests/model_fields/tests.py
@@ -8,6 +8,7 @@ from django import forms
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.fields.files import FieldFile
+from django.utils import six
from django.utils import unittest
from .models import (Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post,
@@ -303,11 +304,11 @@ class BigIntegerFieldTests(test.TestCase):
def test_types(self):
b = BigInt(value = 0)
- self.assertTrue(isinstance(b.value, (int, long)))
+ self.assertTrue(isinstance(b.value, six.integer_types))
b.save()
- self.assertTrue(isinstance(b.value, (int, long)))
+ self.assertTrue(isinstance(b.value, six.integer_types))
b = BigInt.objects.all()[0]
- self.assertTrue(isinstance(b.value, (int, long)))
+ self.assertTrue(isinstance(b.value, six.integer_types))
def test_coercing(self):
BigInt.objects.create(value ='10')