diff options
| author | Tim Graham <timograham@gmail.com> | 2015-06-08 09:11:11 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-06-08 11:03:10 -0400 |
| commit | 167a3203b645341a3b00b878594bfd8d4dd6b040 (patch) | |
| tree | df26cef54c8e67a8c47c9a6f2918c0888d4ab2cd /tests/db_functions | |
| parent | 1f5b067710a6bc97848b1caff0e2a685c2489868 (diff) | |
Fixed tests for refs #24767 on databases that don't support microseconds.
Diffstat (limited to 'tests/db_functions')
| -rw-r--r-- | tests/db_functions/tests.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/db_functions/tests.py b/tests/db_functions/tests.py index 8d465b1bd3..a401c550fb 100644 --- a/tests/db_functions/tests.py +++ b/tests/db_functions/tests.py @@ -20,6 +20,10 @@ lorem_ipsum = """ tempor incididunt ut labore et dolore magna aliqua.""" +def truncate_microseconds(value): + return value if connection.features.supports_microsecond_precision else value.replace(microsecond=0) + + class FunctionTests(TestCase): def test_coalesce(self): @@ -117,7 +121,7 @@ class FunctionTests(TestCase): articles = Article.objects.annotate( last_updated=Greatest('written', 'published'), ) - self.assertEqual(articles.first().last_updated, now) + self.assertEqual(articles.first().last_updated, truncate_microseconds(now)) @skipUnlessDBFeature('greatest_least_ignores_nulls') def test_greatest_ignores_null(self): @@ -170,7 +174,7 @@ class FunctionTests(TestCase): Coalesce('published', past_sql), ), ) - self.assertEqual(articles.first().last_updated, now) + self.assertEqual(articles.first().last_updated, truncate_microseconds(now)) def test_greatest_all_null(self): Article.objects.create(title="Testing with Django", written=timezone.now()) @@ -212,7 +216,7 @@ class FunctionTests(TestCase): articles = Article.objects.annotate( first_updated=Least('written', 'published'), ) - self.assertEqual(articles.first().first_updated, before) + self.assertEqual(articles.first().first_updated, truncate_microseconds(before)) @skipUnlessDBFeature('greatest_least_ignores_nulls') def test_least_ignores_null(self): @@ -265,7 +269,7 @@ class FunctionTests(TestCase): Coalesce('published', future_sql), ), ) - self.assertEqual(articles.first().last_updated, now) + self.assertEqual(articles.first().last_updated, truncate_microseconds(now)) def test_least_all_null(self): Article.objects.create(title="Testing with Django", written=timezone.now()) |
