diff options
| author | Tim Graham <timograham@gmail.com> | 2016-07-15 15:54:11 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-07-16 08:22:24 -0400 |
| commit | 7c33aa8a87d323f0e8e5368705aa8ba96f9819d0 (patch) | |
| tree | 209b3f70add084d1c0e82f61d25a10f3141fc35c /tests/model_fields | |
| parent | 255fb992845e987ef36e3d721a77747a0b2df620 (diff) | |
Fixed #26900 -- Fixed crash accessing deferred FileFields.
Diffstat (limited to 'tests/model_fields')
| -rw-r--r-- | tests/model_fields/test_filefield.py | 4 | ||||
| -rw-r--r-- | tests/model_fields/test_imagefield.py | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/model_fields/test_filefield.py b/tests/model_fields/test_filefield.py index 3b0ef5726d..19d414161d 100644 --- a/tests/model_fields/test_filefield.py +++ b/tests/model_fields/test_filefield.py @@ -50,3 +50,7 @@ class FileFieldTests(TestCase): d = Document.objects.create(myfile='something.txt') d.refresh_from_db() self.assertIs(d.myfile.instance, d) + + def test_defer(self): + Document.objects.create(myfile='something.txt') + self.assertEqual(Document.objects.defer('myfile')[0].myfile, 'something.txt') diff --git a/tests/model_fields/test_imagefield.py b/tests/model_fields/test_imagefield.py index 51f91d90c0..a70394795f 100644 --- a/tests/model_fields/test_imagefield.py +++ b/tests/model_fields/test_imagefield.py @@ -194,6 +194,13 @@ class ImageFieldTests(ImageFieldTestMixin, TestCase): loaded_p = pickle.loads(dump) self.assertEqual(p.mugshot, loaded_p.mugshot) + def test_defer(self): + self.PersonModel.objects.create(name='Joe', mugshot=self.file1) + with self.assertNumQueries(1): + qs = list(self.PersonModel.objects.defer('mugshot')) + with self.assertNumQueries(0): + self.assertEqual(qs[0].name, 'Joe') + @skipIf(Image is None, "Pillow is required to test ImageField") class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase): |
