Ticket #31506: test_31506.diff

File test_31506.diff, 1.1 KB (added by Mariusz Felisiak, 5 years ago)
  • tests/expressions/tests.py

    diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
    index b17a286d5d..c4a573028e 100644
    a b class IterableLookupInnerExpressionsTests(TestCase):  
    900900        queryset = Result.objects.filter(result_time__range=within_experiment_time)
    901901        self.assertQuerysetEqual(queryset, ["<Result: Result at 2016-02-04 15:00:00>"])
    902902
     903    def test_31506(self):
     904        start = datetime.datetime(2016, 2, 3, 15, 0, 0)
     905        end = datetime.datetime(2016, 2, 5, 15, 0, 0)
     906        experiment_1 = Experiment.objects.create(
     907            name='Integrity testing',
     908            assigned=start.date(),
     909            start=start,
     910            end=end,
     911            completed=end.date(),
     912            estimated_time=end - start,
     913        )
     914        qs = Experiment.objects.annotate(
     915            wrapped_date=ExpressionWrapper(
     916                F('assigned') - datetime.timedelta(days=1),
     917                output_field=DateField(),
     918            ),
     919        )
     920        self.assertEqual(qs.first().wrapped_date, datetime.date(2016, 2, 2))
     921
    903922
    904923class FTests(SimpleTestCase):
    905924
Back to Top