diff options
author | Petri Lehtinen <petri@digip.org> | 2013-02-26 19:46:12 (GMT) |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2013-02-26 19:46:12 (GMT) |
commit | e55aa69efc048ef4a9eb7525ad2fd74fd3dfbf05 (patch) | |
tree | b05e5b83a130f4e04b0e4b1e18526a20b370aa2c /Lib/sqlite3/test | |
parent | 8ff7f7207c706e3c931c0f2c80923a472ef2e351 (diff) | |
parent | 6401ad66a76a2e447aad0c0aed173926b66acfd9 (diff) | |
download | cpython-e55aa69efc048ef4a9eb7525ad2fd74fd3dfbf05.zip cpython-e55aa69efc048ef4a9eb7525ad2fd74fd3dfbf05.tar.gz cpython-e55aa69efc048ef4a9eb7525ad2fd74fd3dfbf05.tar.bz2 |
Issue #14720: Enhance sqlite3 microsecond conversion, document its behavior
Diffstat (limited to 'Lib/sqlite3/test')
-rw-r--r-- | Lib/sqlite3/test/regression.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py index 87d2cce..5e2fbf9 100644 --- a/Lib/sqlite3/test/regression.py +++ b/Lib/sqlite3/test/regression.py @@ -313,11 +313,20 @@ class RegressionTests(unittest.TestCase): con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES) cur = con.cursor() cur.execute("CREATE TABLE t (x TIMESTAMP)") + + # Microseconds should be 456000 cur.execute("INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.456')") + + # Microseconds should be truncated to 123456 + cur.execute("INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.123456789')") + cur.execute("SELECT * FROM t") - date = cur.fetchall()[0][0] + values = [x[0] for x in cur.fetchall()] - self.assertEqual(date, datetime.datetime(2012, 4, 4, 15, 6, 0, 456000)) + self.assertEqual(values, [ + datetime.datetime(2012, 4, 4, 15, 6, 0, 456000), + datetime.datetime(2012, 4, 4, 15, 6, 0, 123456), + ]) def suite(): |