summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3/test
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2013-02-23 18:10:29 (GMT)
committerPetri Lehtinen <petri@digip.org>2013-02-23 18:10:29 (GMT)
commite460f26b2582606faa7b64e5dc8643b560472f0d (patch)
tree6e7ad4dfaa1a88ea52c65a9ce18d01012e166109 /Lib/sqlite3/test
parent20054477f4671150e098b519dc1b85d7db6d27ab (diff)
parentf484efdb60cf97d04eed4f87f838ad27e1ed241f (diff)
downloadcpython-e460f26b2582606faa7b64e5dc8643b560472f0d.zip
cpython-e460f26b2582606faa7b64e5dc8643b560472f0d.tar.gz
cpython-e460f26b2582606faa7b64e5dc8643b560472f0d.tar.bz2
Issue #14720: sqlite3: Convert datetime microseconds correctly
Diffstat (limited to 'Lib/sqlite3/test')
-rw-r--r--Lib/sqlite3/test/regression.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
index 9d7b276..87d2cce 100644
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -302,6 +302,23 @@ class RegressionTests(unittest.TestCase):
cur.executemany("insert into b (baz) values (?)",
((i,) for i in foo()))
+ def CheckConvertTimestampMicrosecondPadding(self):
+ """
+ http://bugs.python.org/issue14720
+
+ The microsecond parsing of convert_timestamp() should pad with zeros,
+ since the microsecond string "456" actually represents "456000".
+ """
+
+ con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES)
+ cur = con.cursor()
+ cur.execute("CREATE TABLE t (x TIMESTAMP)")
+ cur.execute("INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.456')")
+ cur.execute("SELECT * FROM t")
+ date = cur.fetchall()[0][0]
+
+ self.assertEqual(date, datetime.datetime(2012, 4, 4, 15, 6, 0, 456000))
+
def suite():
regression_suite = unittest.makeSuite(RegressionTests, "Check")