diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2015-04-04 12:22:30 -0700 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-04-06 22:45:36 +0200 |
| commit | 551d4bb46a3db7afed2d9bab4b27628a0a44b0fc (patch) | |
| tree | e63d2d557d8fdc14482894fc5f2bdb716cc5fc74 /tests | |
| parent | 773387ce42de1c355e6ed6b9ddd49dc52474fc0a (diff) | |
[1.8.x] Fixed #24584 -- Fixed microsecond handling with older MySQLdb
Backport of 2cf58e80d from master.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basic/tests.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/basic/tests.py b/tests/basic/tests.py index ee6587ddce..e5c70b22e3 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -192,15 +192,30 @@ class ModelTest(TestCase): @skipIfDBFeature('supports_microsecond_precision') def test_microsecond_precision_not_supported(self): - # In MySQL, microsecond-level precision isn't available. You'll lose - # microsecond-level precision once the data is saved. + # In MySQL, microsecond-level precision isn't always available. You'll + # lose microsecond-level precision once the data is saved. a9 = Article( headline='Article 9', pub_date=datetime(2005, 7, 31, 12, 30, 45, 180), ) a9.save() - self.assertEqual(Article.objects.get(id__exact=a9.id).pub_date, - datetime(2005, 7, 31, 12, 30, 45)) + self.assertEqual( + Article.objects.get(id__exact=a9.id).pub_date, + datetime(2005, 7, 31, 12, 30, 45), + ) + + @skipIfDBFeature('supports_microsecond_precision') + def test_microsecond_precision_not_supported_edge_case(self): + # In MySQL, microsecond-level precision isn't always available. You'll + # lose microsecond-level precision once the data is saved. + a = Article.objects.create( + headline='Article', + pub_date=datetime(2008, 12, 31, 23, 59, 59, 999999), + ) + self.assertEqual( + Article.objects.get(pk=a.pk).pub_date, + datetime(2008, 12, 31, 23, 59, 59), + ) def test_manually_specify_primary_key(self): # You can manually specify the primary key when creating a new object. |
