(self)
| 2331 | |
| 2332 | @skipUnlessDBFeature("supports_temporal_subtraction") |
| 2333 | def test_datetime_subtraction(self): |
| 2334 | under_estimate = [ |
| 2335 | e.name |
| 2336 | for e in Experiment.objects.filter(estimated_time__gt=F("end") - F("start")) |
| 2337 | ] |
| 2338 | self.assertEqual(under_estimate, ["e2"]) |
| 2339 | |
| 2340 | over_estimate = [ |
| 2341 | e.name |
| 2342 | for e in Experiment.objects.filter(estimated_time__lt=F("end") - F("start")) |
| 2343 | ] |
| 2344 | self.assertEqual(over_estimate, ["e4"]) |
| 2345 | |
| 2346 | queryset = Experiment.objects.annotate( |
| 2347 | difference=F("start") - Value(None, output_field=DateTimeField()), |
| 2348 | ) |
| 2349 | self.assertIsNone(queryset.first().difference) |
| 2350 | |
| 2351 | queryset = Experiment.objects.annotate( |
| 2352 | shifted=ExpressionWrapper( |
| 2353 | F("start") - Value(None, output_field=DurationField()), |
| 2354 | output_field=DateTimeField(), |
| 2355 | ) |
| 2356 | ) |
| 2357 | self.assertIsNone(queryset.first().shifted) |
| 2358 | |
| 2359 | @skipUnlessDBFeature("supports_temporal_subtraction") |
| 2360 | def test_datetime_subquery_subtraction(self): |
nothing calls this directly
no test coverage detected