Ticket #13328: 13328_test.diff

File 13328_test.diff, 1.5 KB (added by Karen Tracey, 15 years ago)
  • tests/regressiontests/queryset_pickle/tests.py

     
    11import pickle
     2import datetime
    23
    34from django.test import TestCase
    45
    5 from models import Group, Event
     6from models import Group, Event, Happening
    67
    7 
    88class PickleabilityTestCase(TestCase):
    99    def assert_pickles(self, qs):
    1010        self.assertEqual(list(pickle.loads(pickle.dumps(qs))), list(qs))
     
    1212    def test_related_field(self):
    1313        g = Group.objects.create(name="Ponies Who Own Maybachs")
    1414        self.assert_pickles(Event.objects.filter(group=g.id))
     15
     16    def test_datetime_callable_default_all(self):
     17        self.assert_pickles(Happening.objects.all())
     18
     19    def test_datetime_callable_default_filter(self):
     20        self.assert_pickles(Happening.objects.filter(when=datetime.datetime.now()))
     21
  • tests/regressiontests/queryset_pickle/models.py

     
     1import datetime
    12from django.db import models
    23from django.utils.translation import ugettext_lazy as _
    34
     
    67
    78class Event(models.Model):
    89    group = models.ForeignKey(Group)
     10
     11class Happening(models.Model):
     12    when = models.DateTimeField(blank=True, default=datetime.datetime.now)
Back to Top