mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[py3] Added Python 3 compatibility for xrange.
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import absolute_import
|
||||
|
||||
from django.db import models, IntegrityError
|
||||
from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
|
||||
from django.utils.six.moves import xrange
|
||||
|
||||
from .models import (R, RChild, S, T, U, A, M, MR, MRNull,
|
||||
create_a, get_default_r, User, Avatar, HiddenUser, HiddenUserProfile)
|
||||
|
||||
@@ -88,8 +88,8 @@ class ManyToOneNullTests(TestCase):
|
||||
|
||||
def test_clear_efficiency(self):
|
||||
r = Reporter.objects.create()
|
||||
for _ in xrange(3):
|
||||
for _ in range(3):
|
||||
r.article_set.create()
|
||||
with self.assertNumQueries(1):
|
||||
r.article_set.clear()
|
||||
self.assertEqual(r.article_set.count(), 0)
|
||||
self.assertEqual(r.article_set.count(), 0)
|
||||
|
||||
@@ -17,6 +17,7 @@ from django.test import (TestCase, skipUnlessDBFeature, skipIfDBFeature,
|
||||
TransactionTestCase)
|
||||
from django.test.utils import override_settings
|
||||
from django.utils import six
|
||||
from django.utils.six.moves import xrange
|
||||
from django.utils import unittest
|
||||
|
||||
from . import models
|
||||
@@ -531,7 +532,7 @@ class ThreadTests(TestCase):
|
||||
from django.db import connection
|
||||
connection.cursor()
|
||||
connections_set.add(connection.connection)
|
||||
for x in xrange(2):
|
||||
for x in range(2):
|
||||
t = threading.Thread(target=runner)
|
||||
t.start()
|
||||
t.join()
|
||||
@@ -558,7 +559,7 @@ class ThreadTests(TestCase):
|
||||
# main thread.
|
||||
conn.allow_thread_sharing = True
|
||||
connections_set.add(conn)
|
||||
for x in xrange(2):
|
||||
for x in range(2):
|
||||
t = threading.Thread(target=runner)
|
||||
t.start()
|
||||
t.join()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from django.dispatch.saferef import safeRef
|
||||
from django.utils.six.moves import xrange
|
||||
from django.utils import unittest
|
||||
|
||||
|
||||
class Test1(object):
|
||||
def x(self):
|
||||
pass
|
||||
@@ -70,4 +70,4 @@ class SaferefTests(unittest.TestCase):
|
||||
|
||||
def _closure(self, ref):
|
||||
"""Dumb utility mechanism to increment deletion counter"""
|
||||
self.closureCount +=1
|
||||
self.closureCount +=1
|
||||
|
||||
@@ -15,6 +15,7 @@ from django.middleware.http import ConditionalGetMiddleware
|
||||
from django.middleware.gzip import GZipMiddleware
|
||||
from django.test import TestCase, RequestFactory
|
||||
from django.test.utils import override_settings
|
||||
from django.utils.six.moves import xrange
|
||||
|
||||
class CommonMiddlewareTest(TestCase):
|
||||
def setUp(self):
|
||||
|
||||
@@ -98,7 +98,7 @@ class SortedDictTests(SimpleTestCase):
|
||||
self.assertEqual(l - len(self.d1), 1)
|
||||
|
||||
def test_dict_equality(self):
|
||||
d = SortedDict((i, i) for i in xrange(3))
|
||||
d = SortedDict((i, i) for i in range(3))
|
||||
self.assertEqual(d, {0: 0, 1: 1, 2: 2})
|
||||
|
||||
def test_tuple_init(self):
|
||||
|
||||
Reference in New Issue
Block a user