summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaulo <commonzenpython@gmail.com>2016-06-04 16:10:37 -0700
committerTim Graham <timograham@gmail.com>2017-08-10 12:06:02 -0400
commitbfb746f983aa741afa3709794e70f1e0ab6040b5 (patch)
tree48b4a70b1d5119d75157dcae5283f881117fd0a4 /tests
parent22ff86ec52bb536ad9d1fa3ee0c9a3d5eb9925c1 (diff)
Refs #16043 -- Refactored internal fields value cache.
* Removed all hardcoded logic for _{fieldname}_cache. * Added an internal API for interacting with the field values cache. Thanks carljm and MarkusH for support.
Diffstat (limited to 'tests')
-rw-r--r--tests/foreign_object/models/article.py4
-rw-r--r--tests/many_to_one/tests.py2
-rw-r--r--tests/one_to_one/tests.py2
3 files changed, 4 insertions, 4 deletions
diff --git a/tests/foreign_object/models/article.py b/tests/foreign_object/models/article.py
index 103661a4a3..10f92d9505 100644
--- a/tests/foreign_object/models/article.py
+++ b/tests/foreign_object/models/article.py
@@ -10,9 +10,9 @@ class ArticleTranslationDescriptor(ForwardManyToOneDescriptor):
def __set__(self, instance, value):
if instance is None:
raise AttributeError("%s must be accessed via instance" % self.field.name)
- setattr(instance, self.cache_name, value)
+ self.field.set_cached_value(instance, value)
if value is not None and not self.field.remote_field.multiple:
- setattr(value, self.field.related.get_cache_name(), instance)
+ self.field.remote_field.set_cached_value(value, instance)
class ColConstraint:
diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py
index aab050234c..5052c6d471 100644
--- a/tests/many_to_one/tests.py
+++ b/tests/many_to_one/tests.py
@@ -461,7 +461,7 @@ class ManyToOneTests(TestCase):
self.assertIs(c.parent, p)
# But if we kill the cache, we get a new object.
- del c._parent_cache
+ del c._state.fields_cache['parent']
self.assertIsNot(c.parent, p)
# Assigning a new object results in that object getting cached immediately.
diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py
index 82a061b736..65257cf7dc 100644
--- a/tests/one_to_one/tests.py
+++ b/tests/one_to_one/tests.py
@@ -207,7 +207,7 @@ class OneToOneTests(TestCase):
self.assertIs(p.restaurant, r)
# But if we kill the cache, we get a new object
- del p._restaurant_cache
+ del p._state.fields_cache['restaurant']
self.assertIsNot(p.restaurant, r)
# Reassigning the Restaurant object results in an immediate cache update