Menu

#417 [Python] date, time and datetime are not correct when got from cur.fetchone()

open
nobody
None
5
2013-02-20
2013-02-20
Jira Trac
No

[Python] date, time and datetime are not correct when got from cur.fetchone()

Test case: http://svn.cubrid.org/cubridapis/python/branches/RB-9.1.0/tests2/python/_05_datetype/DataTypeTest.py

Test Environment:
{noformat}
cubrid_rel: 9.1.0.0201
python driver: http://svn.cubrid.org/cubridapis/python/branches/RB-9.1.0 1491
python: 2.6.5
{noformat}

Test codes:
{noformat}
def test_date(self):
# test normal date type
dataList = [date.min,date.today(),date.max]
sqlInsert = insert into datetime_db(c_date) values
for i in dataList:
sqlInsert = sqlInsert + (' + i.isoformat() + '),
sqlInsert = sqlInsert.rstrip(',')
rowNum = self.cur.execute(sqlInsert)
sqlSelect = select * from datetime_db
self.cur.execute(sqlSelect)
for i in range(rowNum):
data = self.cur.fetchone()
self.assertEquals(dataList[i].isoformat(), data[0])

{noformat}

In this test file, this issue caused 4 test methods failed:
test_date, test_datetime, test_time, test_timestamp

Test error logs
{noformat}
======================================================================
FAIL: test_date (__main__.FetchoneTypeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File python/_05_datetype/DataTypeTest.py, line 208, in test_date
self.assertEquals(dataList[i].isoformat(), data[0])
AssertionError: '0001-01-01' != datetime.date(1, 1, 1)

======================================================================
FAIL: test_datetime (__main__.FetchoneTypeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File python/_05_datetype/DataTypeTest.py, line 237, in test_datetime
self.assertEquals('0001-01-01 00:00:00.000', data[2])
AssertionError: '0001-01-01 00:00:00.000' != datetime.datetime(1, 1, 1, 0, 0)

======================================================================
FAIL: test_time (__main__.FetchoneTypeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File python/_05_datetype/DataTypeTest.py, line 222, in test_time
self.assertEquals(dataList[i].isoformat().rstrip('9').rstrip('.'), data[1])
AssertionError: '00:00:00' != datetime.time(0, 0)

======================================================================
FAIL: test_timestamp (__main__.FetchoneTypeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File python/_05_datetype/DataTypeTest.py, line 252, in test_timestamp
self.assertEquals(dataCheck[i], data[0])
AssertionError: '2012-10-31 00:00:00' != datetime.datetime(2013, 10, 31, 0, 0)

{noformat}

This issues are not existed in versions before

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.