diff options
| author | Josh Smeaton <josh.smeaton@gmail.com> | 2015-03-16 15:51:23 +1100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-03-17 08:36:15 -0400 |
| commit | 34e09e532da41d56d3ba68babd05c4fd848abaa2 (patch) | |
| tree | cf85977b562305e8ab488cb54b5541104d3b5447 /tests | |
| parent | e150bbd4d65b4b2c3897bdabdda94eba508747a2 (diff) | |
[1.8.x] Fixed #24486 -- Fixed error with datetime and DurationField arithmetic
Backport of ff2aa4019259947734c4791d6afc9f5405d901d0 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/expressions/tests.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 59fd063103..6297d68095 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -617,8 +617,8 @@ class ExpressionOperatorTests(TestCase): class FTimeDeltaTests(TestCase): def setUp(self): - sday = datetime.date(2010, 6, 25) - stime = datetime.datetime(2010, 6, 25, 12, 15, 30, 747000) + self.sday = sday = datetime.date(2010, 6, 25) + self.stime = stime = datetime.datetime(2010, 6, 25, 12, 15, 30, 747000) midnight = datetime.time(0) delta0 = datetime.timedelta(0) @@ -821,6 +821,15 @@ class FTimeDeltaTests(TestCase): Experiment.objects.filter(estimated_time__lt=F('end') - F('start'))] self.assertEqual(over_estimate, ['e4']) + def test_duration_with_datetime(self): + # Exclude e1 which has very high precision so we can test this on all + # backends regardless of whether or not it supports + # microsecond_precision. + over_estimate = Experiment.objects.exclude(name='e1').filter( + completed__gt=self.stime + F('estimated_time'), + ).order_by('name') + self.assertQuerysetEqual(over_estimate, ['e3', 'e4'], lambda e: e.name) + class ValueTests(TestCase): def test_update_TimeField_using_Value(self): |
