Ticket #27937: 0001-Demonstrate-that-queryset_result_cache-persists-ac.patch

File 0001-Demonstrate-that-queryset_result_cache-persists-ac.patch, 1.7 KB (added by Luke Benstead, 8 years ago)
  • tests/model_forms/tests.py

    From a1b1df2d887f527f710d970654dea96321060325 Mon Sep 17 00:00:00 2001
    From: Luke Benstead <kazade@gmail.com>
    Date: Tue, 14 Mar 2017 13:12:16 +0000
    Subject: [PATCH] Demonstrate that .queryset._result_cache persists across form
     instantiations
    
    ---
     tests/model_forms/tests.py | 7 +++++++
     1 file changed, 7 insertions(+)
    
    diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
    index b92ba1f..47236a6 100644
    a b class LimitChoicesToTests(TestCase):  
    28152815    """
    28162816    Tests the functionality of ``limit_choices_to``.
    28172817    """
     2818
    28182819    @classmethod
    28192820    def setUpTestData(cls):
    28202821        cls.threepwood = Character.objects.create(
    class LimitChoicesToTests(TestCase):  
    28312832        A ForeignKey can use limit_choices_to as a callable (#2554).
    28322833        """
    28332834        stumpjokeform = StumpJokeForm()
     2835
     2836        # Check that the result_cache is empty for new forms
     2837        self.assertFalse(stumpjokeform.fields['most_recently_fooled'].queryset._result_cache)
    28342838        self.assertSequenceEqual(stumpjokeform.fields['most_recently_fooled'].queryset, [self.threepwood])
    28352839
    28362840    def test_limit_choices_to_callable_for_m2m_rel(self):
    class LimitChoicesToTests(TestCase):  
    28382842        A ManyToManyField can use limit_choices_to as a callable (#2554).
    28392843        """
    28402844        stumpjokeform = StumpJokeForm()
     2845
     2846        # Check that the result_cache is empty for new forms
     2847        self.assertFalse(stumpjokeform.fields['most_recently_fooled'].queryset._result_cache)
    28412848        self.assertSequenceEqual(stumpjokeform.fields['most_recently_fooled'].queryset, [self.threepwood])
    28422849
    28432850    def test_custom_field_with_queryset_but_no_limit_choices_to(self):
Back to Top