<s> """<STR_LIT>""" <EOL> import cx_Oracle <EOL> import sys <EOL> class TestCursor ( BaseTestCase ) : <EOL> def testExecuteNoArgs ( self ) : <EOL> """<STR_LIT>""" <EOL> result = self . cursor . execute ( "<STR_LIT>" ) <EOL> self . failUnlessEqual ( result , None ) <EOL> def testExecuteNoStatementWithArgs ( self ) : <EOL> """<STR_LIT>""" <EOL> self . failUnlessRaises ( cx_Oracle . ProgrammingError , self . cursor . execute , <EOL> None , x = <NUM_LIT:5> ) <EOL> def testExecuteEmptyKeywordArgs ( self ) : <EOL> """<STR_LIT>""" <EOL> simpleVar = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> args = [ simpleVar ] <EOL> kwArgs = { } <EOL> result = self . cursor . execute ( "<STR_LIT>" , args , ** kwArgs ) <EOL> self . failUnlessEqual ( result , None ) <EOL> self . failUnlessEqual ( simpleVar . getvalue ( ) , <NUM_LIT> ) <EOL> def testExecuteKeywordArgs ( self ) : <EOL> """<STR_LIT>""" <EOL> simpleVar = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> result = self . cursor . execute ( "<STR_LIT>" , <EOL> p_Value = simpleVar ) <EOL> self . failUnlessEqual ( result , None ) <EOL> self . failUnlessEqual ( simpleVar . getvalue ( ) , <NUM_LIT:5> ) <EOL> def testExecuteDictionaryArg ( self ) : <EOL> """<STR_LIT>""" <EOL> simpleVar = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> dictArg = { "<STR_LIT>" : simpleVar } <EOL> result = self . cursor . execute ( "<STR_LIT>" , dictArg ) <EOL> self . failUnlessEqual ( result , None ) <EOL> self . failUnlessEqual ( simpleVar . getvalue ( ) , <NUM_LIT:10> ) <EOL> def testExecuteMultipleMethod ( self ) : <EOL> """<STR_LIT>""" <EOL> simpleVar = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> dictArg = { "<STR_LIT>" : simpleVar } <EOL> self . failUnlessRaises ( cx_Oracle . InterfaceError , self . cursor . execute , <EOL> "<STR_LIT>" , dictArg , p_Value = simpleVar ) <EOL> def testExecuteAndModifyArraySize ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> self . cursor . arraysize = <NUM_LIT:20> <EOL> self . failUnlessEqual ( len ( self . cursor . fetchall ( ) ) , <NUM_LIT:10> ) <EOL> def testCallProc ( self ) : <EOL> """<STR_LIT>""" <EOL> var = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> results = self . cursor . callproc ( "<STR_LIT>" , ( "<STR_LIT>" , <NUM_LIT:5> , var ) ) <EOL> self . failUnlessEqual ( results , [ "<STR_LIT>" , <NUM_LIT:10> , <NUM_LIT> ] ) <EOL> def testCallProcNoArgs ( self ) : <EOL> """<STR_LIT>""" <EOL> results = self . cursor . callproc ( "<STR_LIT>" ) <EOL> self . failUnlessEqual ( results , [ ] ) <EOL> def testCallFunc ( self ) : <EOL> """<STR_LIT>""" <EOL> results = self . cursor . callfunc ( "<STR_LIT>" , cx_Oracle . NUMBER , <EOL> ( "<STR_LIT>" , <NUM_LIT:5> ) ) <EOL> self . failUnlessEqual ( results , <NUM_LIT:7> ) <EOL> def testCallFuncNoArgs ( self ) : <EOL> """<STR_LIT>""" <EOL> results = self . cursor . callfunc ( "<STR_LIT>" , cx_Oracle . NUMBER ) <EOL> self . failUnlessEqual ( results , <NUM_LIT> ) <EOL> def testExecuteManyByName ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> rows = [ { "<STR_LIT:value>" : n } for n in range ( <NUM_LIT> ) ] <EOL> self . cursor . arraysize = <NUM_LIT:100> <EOL> statement = "<STR_LIT>" <EOL> self . cursor . executemany ( statement , rows ) <EOL> self . connection . commit ( ) <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> count , = self . cursor . fetchone ( ) <EOL> self . failUnlessEqual ( count , len ( rows ) ) <EOL> def testExecuteManyByPosition ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> rows = [ [ n ] for n in range ( <NUM_LIT> ) ] <EOL> self . cursor . arraysize = <NUM_LIT:100> <EOL> statement = "<STR_LIT>" <EOL> self . cursor . executemany ( statement , rows ) <EOL> self . connection . commit ( ) <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> count , = self . cursor . fetchone ( ) <EOL> self . failUnlessEqual ( count , len ( rows ) ) <EOL> def testExecuteManyWithPrepare ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> rows = [ [ n ] for n in range ( <NUM_LIT> ) ] <EOL> self . cursor . arraysize = <NUM_LIT:100> <EOL> statement = "<STR_LIT>" <EOL> self . cursor . prepare ( statement ) <EOL> self . cursor . executemany ( None , rows ) <EOL> self . connection . commit ( ) <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> count , = self . cursor . fetchone ( ) <EOL> self . failUnlessEqual ( count , len ( rows ) ) <EOL> def testExecuteManyWithRebind ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> rows = [ [ n ] for n in range ( <NUM_LIT> ) ] <EOL> self . cursor . arraysize = <NUM_LIT:100> <EOL> statement = "<STR_LIT>" <EOL> self . cursor . executemany ( statement , rows [ : <NUM_LIT:50> ] ) <EOL> self . cursor . executemany ( statement , rows [ <NUM_LIT:50> : ] ) <EOL> self . connection . commit ( ) <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> count , = self . cursor . fetchone ( ) <EOL> self . failUnlessEqual ( count , len ( rows ) ) <EOL> def testExecuteManyWithResize ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> rows = [ ( <NUM_LIT:1> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:2> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:3> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:4> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:5> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:6> , "<STR_LIT>" ) , <EOL> ( <NUM_LIT:7> , "<STR_LIT>" ) ] <EOL> self . cursor . bindarraysize = <NUM_LIT:5> <EOL> self . cursor . setinputsizes ( int , <NUM_LIT:100> ) <EOL> sql = "<STR_LIT>" <EOL> self . cursor . executemany ( sql , rows ) <EOL> var = self . cursor . bindvars [ <NUM_LIT:1> ] <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> count , = self . cursor . fetchone ( ) <EOL> self . failUnlessEqual ( count , len ( rows ) ) <EOL> self . failUnlessEqual ( var . maxlength , <EOL> <NUM_LIT:100> * self . connection . maxBytesPerCharacter ) <EOL> def testExecuteManyWithExecption ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> rows = [ { "<STR_LIT>" : n } for n in ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:5> ) ] <EOL> statement = "<STR_LIT>" <EOL> self . failUnlessRaises ( cx_Oracle . DatabaseError , self . cursor . executemany , <EOL> statement , rows ) <EOL> self . failUnlessEqual ( self . cursor . rowcount , <NUM_LIT:3> ) <EOL> def testPrepare ( self ) : <EOL> """<STR_LIT>""" <EOL> self . failUnlessEqual ( self . cursor . statement , None ) <EOL> statement = "<STR_LIT>" <EOL> self . cursor . prepare ( statement ) <EOL> var = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> self . failUnlessEqual ( self . cursor . statement , statement ) <EOL> var . setvalue ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> self . cursor . execute ( None , p_Value = var ) <EOL> self . failUnlessEqual ( var . getvalue ( ) , <NUM_LIT:7> ) <EOL> self . cursor . execute ( None , p_Value = var ) <EOL> self . failUnlessEqual ( var . getvalue ( ) , <NUM_LIT:12> ) <EOL> self . cursor . execute ( "<STR_LIT>" , p_Value2 = var ) <EOL> self . failUnlessEqual ( var . getvalue ( ) , <NUM_LIT:3> ) <EOL> def testExceptionOnClose ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . close ( ) <EOL> self . failUnlessRaises ( cx_Oracle . InterfaceError , self . cursor . execute , <EOL> "<STR_LIT>" ) <EOL> def testIterators ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cursor . execute ( """<STR_LIT>""" ) <EOL> rows = [ ] <EOL> for row in self . cursor : <EOL> rows . append ( row [ <NUM_LIT:0> ] ) <EOL> self . failUnlessEqual ( rows , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> def testIteratorsInterrupted ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> self . cursor . execute ( """<STR_LIT>""" ) <EOL> testIter = iter ( self . cursor ) <EOL> if sys . version_info [ <NUM_LIT:0> ] >= <NUM_LIT:3> : <EOL> value , = next ( testIter ) <EOL> else : <EOL> value , = testIter . next ( ) <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> if sys . version_info [ <NUM_LIT:0> ] >= <NUM_LIT:3> : <EOL> self . failUnlessRaises ( cx_Oracle . InterfaceError , next , testIter ) <EOL> else : <EOL> self . failUnlessRaises ( cx_Oracle . InterfaceError , testIter . next ) <EOL> def testBindNames ( self ) : <EOL> """<STR_LIT>""" <EOL> self . failUnlessRaises ( cx_Oracle . ProgrammingError , <EOL> self . cursor . bindnames ) <EOL> self . cursor . prepare ( "<STR_LIT>" ) <EOL> self . failUnlessEqual ( self . cursor . bindnames ( ) , [ ] ) <EOL> self . cursor . prepare ( "<STR_LIT>" ) <EOL> self . failUnlessEqual ( self . cursor . bindnames ( ) , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . cursor . prepare ( "<STR_LIT>" ) <EOL> self . failUnlessEqual ( self . cursor . bindnames ( ) , [ "<STR_LIT>" , "<STR_LIT:A>" , "<STR_LIT:B>" ] ) <EOL> self . cursor . prepare ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> self . failUnlessEqual ( self . cursor . bindnames ( ) , <EOL> [ "<STR_LIT:A>" , "<STR_LIT:B>" , "<STR_LIT:C>" , "<STR_LIT:D>" , "<STR_LIT:E>" , "<STR_LIT:F>" , "<STR_LIT>" , "<STR_LIT:H>" , "<STR_LIT:I>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:L>" ] ) <EOL> def testBadPrepare ( self ) : <EOL> """<STR_LIT>""" <EOL> self . failUnlessRaises ( cx_Oracle . DatabaseError , <EOL> self . cursor . execute , <EOL> "<STR_LIT>" ) <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> def testBadExecute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . failUnlessRaises ( cx_Oracle . DatabaseError , <EOL> self . cursor . execute , "<STR_LIT>" ) <EOL> self . failUnlessRaises ( cx_Oracle . InterfaceError , <EOL> self . cursor . fetchall ) <EOL> def testSetInputSizesMultipleMethod ( self ) : <EOL> """<STR_LIT>""" <EOL> self . failUnlessRaises ( cx_Oracle . InterfaceError , <EOL> self . cursor . setinputsizes , <NUM_LIT:5> , x = <NUM_LIT:5> ) <EOL> def testSetInputSizesByPosition ( self ) : <EOL> """<STR_LIT>""" <EOL> var = self . cursor . var ( cx_Oracle . STRING , <NUM_LIT:100> ) <EOL> self . cursor . setinputsizes ( None , <NUM_LIT:5> , None , <NUM_LIT:10> , None , cx_Oracle . NUMBER ) <EOL> self . cursor . execute ( """<STR_LIT>""" , [ var , '<STR_LIT>' , <NUM_LIT:5> , '<STR_LIT>' , <NUM_LIT:3> , <NUM_LIT:7> ] ) <EOL> self . failUnlessEqual ( var . getvalue ( ) , "<STR_LIT>" ) </s>
