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):
|
2815 | 2815 | """ |
2816 | 2816 | Tests the functionality of ``limit_choices_to``. |
2817 | 2817 | """ |
| 2818 | |
2818 | 2819 | @classmethod |
2819 | 2820 | def setUpTestData(cls): |
2820 | 2821 | cls.threepwood = Character.objects.create( |
… |
… |
class LimitChoicesToTests(TestCase):
|
2831 | 2832 | A ForeignKey can use limit_choices_to as a callable (#2554). |
2832 | 2833 | """ |
2833 | 2834 | 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) |
2834 | 2838 | self.assertSequenceEqual(stumpjokeform.fields['most_recently_fooled'].queryset, [self.threepwood]) |
2835 | 2839 | |
2836 | 2840 | def test_limit_choices_to_callable_for_m2m_rel(self): |
… |
… |
class LimitChoicesToTests(TestCase):
|
2838 | 2842 | A ManyToManyField can use limit_choices_to as a callable (#2554). |
2839 | 2843 | """ |
2840 | 2844 | 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) |
2841 | 2848 | self.assertSequenceEqual(stumpjokeform.fields['most_recently_fooled'].queryset, [self.threepwood]) |
2842 | 2849 | |
2843 | 2850 | def test_custom_field_with_queryset_but_no_limit_choices_to(self): |