[pywin32-checkins] pywin32/win32/test test_odbc.py,1.7,1.7.2.1
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2008-09-17 03:21:01
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5902 Modified Files: Tag: py3k test_odbc.py Log Message: Add tests for raw binary field and extended unicode chars Index: test_odbc.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_odbc.py,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** test_odbc.py 24 May 2007 05:38:35 -0000 1.7 --- test_odbc.py 17 Sep 2008 03:21:09 -0000 1.7.2.1 *************** *** 4,8 **** import unittest import odbc - import dbi import tempfile --- 4,7 ---- *************** *** 33,37 **** pass else: ! raise RuntimeError, "Can't find a DB engine" workspace = dbe.Workspaces(0) --- 32,36 ---- pass else: ! raise RuntimeError("Can't find a DB engine") workspace = dbe.Workspaces(0) *************** *** 50,63 **** try: self.cur.execute("""drop table pywin32test_users""") ! except (odbc.error, dbi.progError): pass self.assertEqual(self.cur.execute( """create table pywin32test_users ( ! userid varchar(5), username varchar(25), ! bitfield bit, intfield integer, floatfield float, datefield date, ! )"""),-1) def tearDown(self): --- 49,65 ---- try: self.cur.execute("""drop table pywin32test_users""") ! except (odbc.error, odbc.progError): pass self.assertEqual(self.cur.execute( """create table pywin32test_users ( ! userid varchar(25), ! username varchar(25), ! bitfield bit, ! intfield integer, floatfield float, datefield date, ! rawfield varbinary(100) ! )"""),-1) def tearDown(self): *************** *** 65,70 **** try: self.cur.execute("""drop table pywin32test_users""") ! except (odbc.error, dbi.progError), why: ! print "Failed to delete test table:", why self.cur.close() --- 67,72 ---- try: self.cur.execute("""drop table pywin32test_users""") ! except (odbc.error, odbc.progError) as why: ! print ("Failed to delete test table:", why) self.cur.close() *************** *** 89,96 **** try: self.test_insert_select(userid='Frank' * 200, username='Frank Millman' * 200) ! except dbi.noError: pass ! def test_insert_select_unicode(self, userid=u'Frank', username=u"Frank Millman"): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid, username)\ values (?,?)", [userid, username]),1) --- 91,98 ---- try: self.test_insert_select(userid='Frank' * 200, username='Frank Millman' * 200) ! except odbc.noError: pass ! def test_insert_select_unicode(self, userid='Frank', username="Frank Millman"): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid, username)\ values (?,?)", [userid, username]),1) *************** *** 101,106 **** def test_insert_select_unicode_ext(self): ! userid = unicode("t-\xe0\xf2", "mbcs") ! username = unicode("test-\xe0\xf2 name", "mbcs") self.test_insert_select_unicode(userid, username) --- 103,108 ---- def test_insert_select_unicode_ext(self): ! userid = str(b"t-\xe0\xf2", "mbcs") ! username = str(b"test-\xe0\xf2 name", "mbcs") self.test_insert_select_unicode(userid, username) *************** *** 124,129 **** self._test_val('intfield', 1) self._test_val('intfield', 0) ! self._test_val('intfield', sys.maxint) ! def testFloat(self): self._test_val('floatfield', 1.01) --- 126,131 ---- self._test_val('intfield', 1) self._test_val('intfield', 0) ! self._test_val('intfield', sys.maxsize) ! def testFloat(self): self._test_val('floatfield', 1.01) *************** *** 133,136 **** --- 135,148 ---- self._test_val('username', 'foo') + def testRaw(self): + ## Test binary data + self._test_val('rawfield', memoryview(b'\1\2\3\4\0\5\6\7\8')) + + def test_widechar(self): + """Test a unicode character that would be mangled if bound as plain character. + For example, previously the below was returned as ascii 'a' + """ + self._test_val('username', '\u0101') + def testDates(self): import datetime *************** *** 139,143 **** ): d = datetime.datetime(*v) ! self._test_val('datefield', 'd') def test_set_nonzero_length(self): --- 151,155 ---- ): d = datetime.datetime(*v) ! self._test_val('datefield', d) def test_set_nonzero_length(self): *************** *** 151,155 **** def test_set_zero_length(self): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid,username) " ! "values (?,?)",['Frank', '']),1) self.assertEqual(self.cur.execute("select * from pywin32test_users"),0) self.assertEqual(len(self.cur.fetchone()[1]),0) --- 163,167 ---- def test_set_zero_length(self): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid,username) " ! "values (?,?)",[b'Frank', '']),1) self.assertEqual(self.cur.execute("select * from pywin32test_users"),0) self.assertEqual(len(self.cur.fetchone()[1]),0) *************** *** 157,161 **** def test_set_zero_length_unicode(self): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid,username) " ! "values (?,?)",[u'Frank', u'']),1) self.assertEqual(self.cur.execute("select * from pywin32test_users"),0) self.assertEqual(len(self.cur.fetchone()[1]),0) --- 169,173 ---- def test_set_zero_length_unicode(self): self.assertEqual(self.cur.execute("insert into pywin32test_users (userid,username) " ! "values (?,?)",['Frank', '']),1) self.assertEqual(self.cur.execute("select * from pywin32test_users"),0) self.assertEqual(len(self.cur.fetchone()[1]),0) |