From ca43ee9d0f4682c989e6b88bbc97ddb706ecff0a Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 7 Oct 2015 12:46:07 -0400 Subject: [PATCH] Refs #17917 -- Added a test for pickling annotations on fields with callable defaults. Fixed in f403653cf146384946e5c879ad2a351768ebc226. --- tests/queryset_pickle/tests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py index 63f4283870..3e038b0c51 100644 --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -5,6 +5,7 @@ import pickle import unittest import warnings +from django.db import models from django.test import TestCase from django.utils import six from django.utils.encoding import force_text @@ -130,6 +131,11 @@ class PickleabilityTestCase(TestCase): m2ms = pickle.loads(pickle.dumps(m2ms)) self.assertQuerysetEqual(m2ms, [m2m], lambda x: x) + def test_annotation_with_callable_default(self): + # Happening.when has a callable default of datetime.datetime.now. + qs = Happening.objects.annotate(latest_time=models.Max('when')) + self.assert_pickles(qs) + def test_missing_django_version_unpickling(self): """ #21430 -- Verifies a warning is raised for querysets that are