Update of /cvsroot/pywin32/pywin32/adodbapi/tests
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16778/tests
Modified Files:
Tag: py3k
adodbapitest.py adodbapitestconfig.py dbapi20.py
test_adodbapi_dbapi20.py
Log Message:
version 2.2.4 after running thru 2to3
Index: adodbapitest.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/adodbapitest.py,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -C2 -d -r1.2.2.2 -r1.2.2.3
*** adodbapitest.py 13 Nov 2008 04:28:21 -0000 1.2.2.2
--- adodbapitest.py 8 Dec 2008 21:35:05 -0000 1.2.2.3
***************
*** 1,5 ****
! """ Unit tests for adodbapi version 2.2.3"""
! from __future__ import print_function
! from __future__ import unicode_literals
"""
adodbapi - A python DB API 2.0 interface to Microsoft ADO
--- 1,3 ----
! """ Unit tests for adodbapi version 2.2.4"""
"""
adodbapi - A python DB API 2.0 interface to Microsoft ADO
***************
*** 34,38 ****
win32 = False
! import adodbapitestconfig #will find (parent?) adodbpai
import adodbapi
--- 32,36 ----
win32 = False
! from import adodbapitestconfig #will find (parent?) adodbpai
import adodbapi
***************
*** 55,59 ****
def getConnection(self):
! raise NotImplementedError("This method must be overriden by a subclass")
def getCursor(self):
--- 53,57 ----
def getConnection(self):
! raise NotImplementedError("This method must be overriden by a subclass")
def getCursor(self):
***************
*** 181,193 ****
if DBAPIDataTypeString=='STRING':
! assert descTuple[1] == adodbapi.STRING, 'was "%s"'%descTuple[1]
elif DBAPIDataTypeString == 'NUMBER':
! assert descTuple[1] == adodbapi.NUMBER, 'was "%s"'%descTuple[1]
elif DBAPIDataTypeString == 'BINARY':
! assert descTuple[1] == adodbapi.BINARY, 'was "%s"'%descTuple[1]
elif DBAPIDataTypeString == 'DATETIME':
! assert descTuple[1] == adodbapi.DATETIME, 'was "%s"'%descTuple[1]
elif DBAPIDataTypeString == 'ROWID':
! assert descTuple[1] == adodbapi.ROWID, 'was "%s"'%descTuple[1]
else:
raise NotImplementedError("DBAPIDataTypeString not provided")
--- 179,191 ----
if DBAPIDataTypeString=='STRING':
! assert descTuple[1] == adodbapi.STRING, 'was "%s" expected "%s"'%(descTuple[1],adodbapi.STRING.values)
elif DBAPIDataTypeString == 'NUMBER':
! assert descTuple[1] == adodbapi.NUMBER, 'was "%s" expected "%s"'%(descTuple[1],adodbapi.NUMBER.values)
elif DBAPIDataTypeString == 'BINARY':
! assert descTuple[1] == adodbapi.BINARY, 'was "%s" expected "%s"'%(descTuple[1],adodbapi.BINARY.values)
elif DBAPIDataTypeString == 'DATETIME':
! assert descTuple[1] == adodbapi.DATETIME, 'was "%s" expected "%s"'%(descTuple[1],adodbapi.DATETIME.values)
elif DBAPIDataTypeString == 'ROWID':
! assert descTuple[1] == adodbapi.ROWID, 'was "%s" expected "%s"'%(descTuple[1],adodbapi.ROWID.values)
else:
raise NotImplementedError("DBAPIDataTypeString not provided")
***************
*** 254,258 ****
def testDataTypeChar(self):
for sqlDataType in ("char(6)","nchar(6)"):
! self.helpTestDataType(sqlDataType,'STRING','spam ',allowedReturnValues=['spam','spam '])
def testDataTypeVarChar(self):
--- 252,256 ----
def testDataTypeChar(self):
for sqlDataType in ("char(6)","nchar(6)"):
! self.helpTestDataType(sqlDataType,'STRING','spam ',allowedReturnValues=['spam','spam','spam ','spam '])
def testDataTypeVarChar(self):
***************
*** 276,283 ****
pass #self.helpTestDataType("BLOB",'BINARY',adodbapi.Binary('\x00\x01\xE2\x40'))
else:
! ## Py3k no longer has the buffer interface for unicode objects
! self.helpTestDataType("binary(4)",'BINARY',adodbapi.Binary(b'\x00\x01\xE2\x40'))
! self.helpTestDataType("varbinary(100)",'BINARY',adodbapi.Binary(b'\x00\x01\xE2\x40'))
! self.helpTestDataType("image",'BINARY',adodbapi.Binary(b'\x00\x01\xE2\x40'))
def helpRollbackTblTemp(self):
--- 274,280 ----
pass #self.helpTestDataType("BLOB",'BINARY',adodbapi.Binary('\x00\x01\xE2\x40'))
else:
! self.helpTestDataType("binary(4)",'BINARY',adodbapi.Binary('\x00\x01\xE2\x40'))
! self.helpTestDataType("varbinary(100)",'BINARY',adodbapi.Binary('\x00\x01\xE2\x40'))
! self.helpTestDataType("image",'BINARY',adodbapi.Binary('\x00\x01\xE2\x40'))
def helpRollbackTblTemp(self):
Index: test_adodbapi_dbapi20.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/test_adodbapi_dbapi20.py,v
retrieving revision 1.1.1.1.2.1
retrieving revision 1.1.1.1.2.2
diff -C2 -d -r1.1.1.1.2.1 -r1.1.1.1.2.2
*** test_adodbapi_dbapi20.py 13 Nov 2008 04:28:21 -0000 1.1.1.1.2.1
--- test_adodbapi_dbapi20.py 8 Dec 2008 21:35:05 -0000 1.1.1.1.2.2
***************
*** 1,13 ****
- from __future__ import print_function
- from __future__ import unicode_literals
print("This module depends on the dbapi20 compliance tests created by Stuart Bishop")
print("(see db-sig mailing list history for info)")
! import dbapi20
print("Tested with dbapi20 %s" % dbapi20.__version__)
import unittest
- import popen2
! import adodbapitestconfig
import adodbapi
--- 1,10 ----
print("This module depends on the dbapi20 compliance tests created by Stuart Bishop")
print("(see db-sig mailing list history for info)")
! from . import dbapi20
print("Tested with dbapi20 %s" % dbapi20.__version__)
import unittest
! from . import adodbapitestconfig
import adodbapi
Index: adodbapitestconfig.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/adodbapitestconfig.py,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -C2 -d -r1.2.2.2 -r1.2.2.3
*** adodbapitestconfig.py 13 Nov 2008 04:28:21 -0000 1.2.2.2
--- adodbapitestconfig.py 8 Dec 2008 21:35:05 -0000 1.2.2.3
***************
*** 1,116 ****
- # Configure this in order to run the testcases.
- "adodbapitestconfig.py v 2.2.3"
- from __future__ import print_function
- from __future__ import unicode_literals
! import os
! import sys
! print(sys.version)
! #attempt to find adodbapi in this directory's parent
! cwd = os.getcwd()
! adoPath = os.path.normpath(cwd + '/../adodbapi.py')
! if os.path.exists(adoPath):
! if adoPath not in sys.path:
! sys.path.insert(1,os.path.dirname(adoPath))
! import adodbapi
! # adodbapitest.py will import this same version when we return
! try:
! print(adodbapi.version) # show version
! except:
! print('"adodbapi.version" not present or not working.')
! print(__doc__)
! doAccessTest = True
! doSqlServerTest = False #True
! doMySqlTest = False #True
! try: #If mx extensions are installed, use mxDateTime
! import mx.DateTime
! doMxDateTimeTest=True
! except:
! doMxDateTimeTest=False #Requires eGenixMXExtensions
! doMySqlTest = False
! doDateTimeTest=True
! iterateOverTimeTests=False
! if doAccessTest:
! _accessdatasource = None #set to None for automatic creation
! #r"C:\Program Files\Microsoft Office\Office\Samples\northwind.mdb;"
! #Typically C:\Program Files
! if _accessdatasource == None:
! # following setup code borrowed from pywin32 odbc test suite
! # kindly contributed by Frank Millman.
! import tempfile
! import os
! try:
! from win32com.client.gencache import EnsureDispatch
! from win32com.client import constants
! win32 = True
! except ImportError: #perhaps we are running IronPython
! win32 = False
! if not win32:
! from System import Activator, Type
! _accessdatasource = os.path.join(tempfile.gettempdir(), "test_odbc.mdb")
! if os.path.isfile(_accessdatasource):
! os.unlink(_accessdatasource)
! # Create a brand-new database - what is the story with these?
! for suffix in (".36", ".35", ".30"):
try:
! if win32:
! dbe = EnsureDispatch("DAO.DBEngine" + suffix)
! else:
! type= Type.GetTypeFromProgID("DAO.DBEngine" + suffix)
! dbe = Activator.CreateInstance(type)
! break
except:
pass
! else:
! raise RuntimeError("Can't find a DB engine")
! print(' ...Creating ACCESS db at',_accessdatasource)
! if win32:
! workspace = dbe.Workspaces(0)
! newdb = workspace.CreateDatabase(_accessdatasource,
! constants.dbLangGeneral,
! constants.dbEncrypt)
! else:
! newdb = dbe.CreateDatabase(_accessdatasource,';LANGID=0x0409;CP=1252;COUNTRY=0')
! newdb.Close()
! connStrAccess = r"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _accessdatasource
! # for ODBC connection try...
! # connStrAccess = "Driver={Microsoft Access Driver (*.mdb)};db=%s;Uid=;Pwd=;" + _accessdatasource
- if True: #needed for dbapi20 test
- _computername="franklin" #or name of computer with SQL Server
- _databasename="Northwind" #or something else
- _username="guest"
- _password="12345678"
- #connStrSQLServer = r"Provider=SQLOLEDB.1; Integrated Security=SSPI; Initial Catalog=%s;Data Source=%s" %(_databasename, _computername)
- connStrSQLServer = r"Provider=SQLOLEDB.1; User ID=%s; Password=%s; Initial Catalog=%s;Data Source=%s" %(_username,_password,_databasename, _computername)
- if doSqlServerTest:
- print(' ...Testing MS-SQL login...')
! try:
! s = adodbapi.connect(connStrSQLServer) #connect to server
! s.close()
! except adodbapi.DatabaseError as inst:
! print(inst.args[0][2]) # should be the error message
! doSqlServerTest = False
! if doMySqlTest:
! _computername='10.100.5.249'
! _databasename='test'
! #_driver="MySQL ODBC 3.51 Driver"
! _driver="MySQL ODBC 5.1 Driver"
! connStrMySql = 'Driver={%s};Server=%s;Port=3306;Database=%s;Option=3;' % \
! (_driver,_computername,_databasename)
! print(' ...Testing MySql login...')
! try:
! s = adodbapi.connect(connStrMySql) #connect to server
! s.close()
! except adodbapi.DatabaseError as inst:
! print(inst.args[0][2]) # should be the error message
! doMySqlTest = False
--- 1,101 ----
! import dbapi20
! print "Tested with dbapi20 %s" % dbapi20.__version__
! import unittest
! from . import adodbapitestconfig
! import adodbapi
! import string
! class test_adodbapi(dbapi20.DatabaseAPI20Test):
! driver = adodbapi
! connect_args = (adodbapitestconfig.connStrSQLServer,)
! connect_kw_args = {}
! def __init__(self,arg):
! dbapi20.DatabaseAPI20Test.__init__(self,arg)
! def testMethodName(self):
! return string.split(self.id(),'.')[-1]
! def setUp(self):
! # Call superclass setUp In case this does something in the
! # future
! dbapi20.DatabaseAPI20Test.setUp(self)
! con = self._connect()
! con.close()
! if self.testMethodName()=='test_callproc':
! sql="""
! create procedure templower
! @theData varchar(50)
! as
! select lower(@theData)
! """
! con = self._connect()
! cur = con.cursor()
try:
! cur.execute(sql)
! con.commit()
except:
pass
! self.lower_func='templower'
! def tearDown(self):
! if self.testMethodName()=='test_callproc':
! con = self._connect()
! cur = con.cursor()
! cur.execute("drop procedure templower")
! con.commit()
! dbapi20.DatabaseAPI20Test.tearDown(self)
!
! def help_nextset_setUp(self,cur):
! 'Should create a procedure called deleteme '
! 'that returns two result sets, first the number of rows in booze then "name from booze"'
! sql="""
! create procedure deleteme as
! begin
! select count(*) from %sbooze
! select name from %sbooze
! end
! """ %(self.table_prefix,self.table_prefix)
! cur.execute(sql)
! def help_nextset_tearDown(self,cur):
! 'If cleaning up is needed after nextSetTest'
! try:
! cur.execute("drop procedure deleteme")
! except:
! pass
!
! def test_nextset(self):
! con = self._connect()
! try:
! cur = con.cursor()
!
! stmts=[self.ddl1] + self._populate()
! for sql in stmts:
! cur.execute(sql)
!
! self.help_nextset_setUp(cur)
!
! cur.callproc('deleteme')
! numberofrows=cur.fetchone()
! assert numberofrows[0]== 6
! assert cur.nextset()
! names=cur.fetchall()
! assert len(names) == len(self.samples)
! s=cur.nextset()
! assert s == None,'No more return sets, should return None'
! finally:
! try:
! self.help_nextset_tearDown(cur)
! finally:
! con.close()
!
! def test_setoutputsize(self): pass
!
! if __name__ == '__main__':
! unittest.main()
Index: dbapi20.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/dbapi20.py,v
retrieving revision 1.1.1.1.2.2
retrieving revision 1.1.1.1.2.3
diff -C2 -d -r1.1.1.1.2.2 -r1.1.1.1.2.3
*** dbapi20.py 13 Nov 2008 04:28:21 -0000 1.1.1.1.2.2
--- dbapi20.py 8 Dec 2008 21:35:05 -0000 1.1.1.1.2.3
***************
*** 20,30 ****
# $Log$
! # Revision 1.1.1.1.2.2 2008/11/13 04:28:21 kf7xm
! # Merge 2.2.2 changes and Test using Python 2.6
! #
!
! # Revision 1.1.1.1.2.1 2008/09/20 19:54:59 rupole
! # Include latest changes from main branch
! # Updates for py3k (reviewed by adodbapi maintainer) -- Done -- V.Cole
#
# Revision 1.2 2008/10/01 14:44:53 mhammond
--- 20,25 ----
# $Log$
! # Revision 1.1.1.1.2.3 2008/12/08 21:35:05 kf7xm
! # version 2.2.4 after running thru 2to3
#
# Revision 1.2 2008/10/01 14:44:53 mhammond
|