From 8424c10d96c9819687fda0a89c7b3a21c745838c Mon Sep 17 00:00:00 2001 From: tumb1er Date: Mon, 16 Aug 2021 18:16:05 +0300 Subject: [PATCH] #407 failing test to demonstrate a bug --- tests/tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/tests.py b/tests/tests.py index a2cb3010..df9e4e16 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -660,6 +660,21 @@ def test_387(self): post = Post.objects.defer("visible").last() post.delete() + def test_407(self): + brand = Brand.objects.create() + pk = brand.pk + label = Label.objects.create() + brand.labels.set([label]) + # Caching + assert len(list(brand.labels.cache()._clone())) == 1 + + brand.delete() + # Invalidation expected after deletionn + brand = Brand.objects.create(pk=pk) + + with self.assertNumQueries(1): + self.assertEqual(len(list(brand.labels.cache()._clone())), 0) + class RelatedTests(BaseTestCase): fixtures = ['basic']