Run 2to3.
This commit is contained in:
parent
a5a8d9dd57
commit
6fa280b9fd
157 changed files with 976 additions and 976 deletions
|
|
@ -6,7 +6,7 @@ leave caching unexpectedly (no use of WeakRefs).
|
|||
|
||||
Also adds `cache_size()` for monitoring the size of the cache.
|
||||
"""
|
||||
from __future__ import absolute_import, division
|
||||
|
||||
from builtins import object
|
||||
from future.utils import listitems, listvalues, with_metaclass
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ class SharedMemoryModelBase(ModelBase):
|
|||
"Setter only used on foreign key relations, allows setting with #dbref"
|
||||
if _GA(cls, "_is_deleted"):
|
||||
raise ObjectDoesNotExist("Cannot set %s to %s: Hosting object was already deleted!" % (fname, value))
|
||||
if isinstance(value, (basestring, int)):
|
||||
if isinstance(value, (str, int)):
|
||||
value = to_str(value, force_string=True)
|
||||
if (value.isdigit() or value.startswith("#")):
|
||||
# we also allow setting using dbrefs, if so we try to load the matching object.
|
||||
|
|
@ -328,7 +328,7 @@ class SharedMemoryModel(with_metaclass(SharedMemoryModelBase, Model)):
|
|||
if force:
|
||||
cls.__dbclass__.__instance_cache__ = {}
|
||||
else:
|
||||
cls.__dbclass__.__instance_cache__ = dict((key, obj) for key, obj in cls.__dbclass__.__instance_cache__.items()
|
||||
cls.__dbclass__.__instance_cache__ = dict((key, obj) for key, obj in list(cls.__dbclass__.__instance_cache__.items())
|
||||
if not obj.at_idmapper_flush())
|
||||
#flush_instance_cache = classmethod(flush_instance_cache)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from builtins import range
|
||||
|
||||
from django.test import TestCase
|
||||
|
|
@ -44,21 +44,21 @@ class SharedMemorysTest(TestCase):
|
|||
article_list = Article.objects.all().select_related('category')
|
||||
last_article = article_list[0]
|
||||
for article in article_list[1:]:
|
||||
self.assertEquals(article.category is last_article.category, True)
|
||||
self.assertEqual(article.category is last_article.category, True)
|
||||
last_article = article
|
||||
|
||||
def testRegularReferences(self):
|
||||
article_list = RegularArticle.objects.all().select_related('category')
|
||||
last_article = article_list[0]
|
||||
for article in article_list[1:]:
|
||||
self.assertEquals(article.category2 is last_article.category2, False)
|
||||
self.assertEqual(article.category2 is last_article.category2, False)
|
||||
last_article = article
|
||||
|
||||
def testMixedReferences(self):
|
||||
article_list = RegularArticle.objects.all().select_related('category')
|
||||
last_article = article_list[0]
|
||||
for article in article_list[1:]:
|
||||
self.assertEquals(article.category is last_article.category, True)
|
||||
self.assertEqual(article.category is last_article.category, True)
|
||||
last_article = article
|
||||
|
||||
#article_list = Article.objects.all().select_related('category')
|
||||
|
|
@ -74,4 +74,4 @@ class SharedMemorysTest(TestCase):
|
|||
article = Article.objects.all()[0:1].get()
|
||||
pk = article.pk
|
||||
article.delete()
|
||||
self.assertEquals(pk not in Article.__instance_cache__, True)
|
||||
self.assertEqual(pk not in Article.__instance_cache__, True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue