<s> from zxtest import zxCoreTestCase <EOL> class OracleSPTest ( zxCoreTestCase ) : <EOL> def setUp ( self ) : <EOL> zxCoreTestCase . setUp ( self ) <EOL> c = self . cursor ( ) <EOL> try : <EOL> try : <EOL> c . execute ( "<STR_LIT>" ) <EOL> except : <EOL> self . db . rollback ( ) <EOL> try : <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> self . db . commit ( ) <EOL> except : <EOL> self . db . rollback ( ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> self . proc_errors ( "<STR_LIT>" ) <EOL> self . proc_errors ( "<STR_LIT>" ) <EOL> finally : <EOL> c . close ( ) <EOL> def tearDown ( self ) : <EOL> zxCoreTestCase . tearDown ( self ) <EOL> def proc_errors ( self , name ) : <EOL> c = self . cursor ( ) <EOL> try : <EOL> c . execute ( "<STR_LIT>" % ( name . upper ( ) ) ) <EOL> errors = c . fetchall ( ) <EOL> try : <EOL> assert not errors , "<STR_LIT>" <EOL> except AssertionError , e : <EOL> print "<STR_LIT>" <EOL> for a in errors : <EOL> print a <EOL> raise e <EOL> finally : <EOL> c . close ( ) <EOL> def testCursor ( self ) : <EOL> c = self . cursor ( ) <EOL> try : <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( """<STR_LIT>""" ) <EOL> c . execute ( """<STR_LIT>""" ) <EOL> self . proc_errors ( "<STR_LIT>" ) <EOL> c . callproc ( "<STR_LIT>" , ( "<STR_LIT:z>" , ) ) <EOL> data = c . fetchall ( ) <EOL> self . assertEquals ( <NUM_LIT:5> , len ( data ) ) <EOL> c . callproc ( "<STR_LIT>" , ( "<STR_LIT:c>" , ) ) <EOL> data = c . fetchall ( ) <EOL> self . assertEquals ( <NUM_LIT:2> , len ( data ) ) <EOL> finally : <EOL> c . close ( ) <EOL> def testProcin ( self ) : <EOL> c = self . cursor ( ) <EOL> try : <EOL> params = [ "<STR_LIT>" ] <EOL> c . callproc ( "<STR_LIT>" , params ) <EOL> self . assertEquals ( [ ] , c . fetchall ( ) ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> self . assertEquals ( <NUM_LIT:1> , len ( c . fetchall ( ) ) ) <EOL> finally : <EOL> c . close ( ) <EOL> def testProcinout ( self ) : <EOL> c = self . cursor ( ) <EOL> try : <EOL> params = [ None , "<STR_LIT>" ] <EOL> c . callproc ( "<STR_LIT>" , params ) <EOL> data = c . fetchone ( ) <EOL> assert data is None , "<STR_LIT>" <EOL> c . execute ( "<STR_LIT>" ) <EOL> data = c . fetchone ( ) <EOL> self . assertEquals ( "<STR_LIT>" , data [ <NUM_LIT:0> ] ) <EOL> self . assertEquals ( "<STR_LIT>" , params [ <NUM_LIT:0> ] ) <EOL> finally : <EOL> c . close ( ) <EOL> def testFuncnone ( self ) : <EOL> c = self . cursor ( ) <EOL> try : <EOL> c . callproc ( "<STR_LIT>" ) <EOL> data = c . fetchone ( ) <EOL> assert data is not None , "<STR_LIT>" <EOL> self . assertEquals ( <NUM_LIT:1> , len ( data ) ) <EOL> self . assertEquals ( "<STR_LIT>" , data [ <NUM_LIT:0> ] ) <EOL> finally : <EOL> c . close ( ) <EOL> def testFuncin ( self ) : <EOL> c = self . cursor ( ) <EOL> try : <EOL> params = [ "<STR_LIT>" ] <EOL> c . callproc ( "<STR_LIT>" , params ) <EOL> self . assertEquals ( <NUM_LIT:1> , c . rowcount ) <EOL> data = c . fetchone ( ) <EOL> assert data is not None , "<STR_LIT>" <EOL> self . assertEquals ( <NUM_LIT:1> , len ( data ) ) <EOL> self . assertEquals ( "<STR_LIT>" , data [ <NUM_LIT:0> ] ) <EOL> finally : <EOL> c . close ( ) <EOL> def testCallingWithKws ( self ) : <EOL> c = self . cursor ( ) <EOL> try : <EOL> params = [ "<STR_LIT>" ] <EOL> c . callproc ( "<STR_LIT>" , params = params ) <EOL> self . assertEquals ( <NUM_LIT:1> , c . rowcount ) <EOL> data = c . fetchone ( ) <EOL> assert data is not None , "<STR_LIT>" <EOL> self . assertEquals ( <NUM_LIT:1> , len ( data ) ) <EOL> self . assertEquals ( "<STR_LIT>" , data [ <NUM_LIT:0> ] ) <EOL> finally : <EOL> c . close ( ) <EOL> def testFuncout ( self ) : <EOL> c = self . cursor ( ) <EOL> try : <EOL> params = [ None ] <EOL> c . callproc ( "<STR_LIT>" , params ) <EOL> data = c . fetchone ( ) <EOL> assert data is not None , "<STR_LIT>" <EOL> self . assertEquals ( <NUM_LIT:1> , len ( data ) ) <EOL> self . assertEquals ( "<STR_LIT>" , data [ <NUM_LIT:0> ] ) <EOL> self . assertEquals ( "<STR_LIT>" , params [ <NUM_LIT:0> ] . strip ( ) ) <EOL> finally : <EOL> c . close ( ) <EOL> def testMultipleFetch ( self ) : <EOL> """<STR_LIT>""" <EOL> c = self . cursor ( ) <EOL> try : <EOL> c . callproc ( "<STR_LIT>" ) <EOL> data = c . fetchone ( ) <EOL> assert data is not None , "<STR_LIT>" <EOL> data = c . fetchone ( ) <EOL> assert data is None , "<STR_LIT>" <EOL> finally : <EOL> c . close ( ) <EOL> class SQLServerSPTest ( zxCoreTestCase ) : <EOL> def testProcWithResultSet ( self ) : <EOL> c = self . cursor ( ) <EOL> try : <EOL> for a in ( ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> try : <EOL> c . execute ( "<STR_LIT>" % ( a ) ) <EOL> except : <EOL> pass <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( "<STR_LIT>" ) <EOL> c . execute ( """<STR_LIT>""" ) <EOL> self . db . commit ( ) <EOL> c . callproc ( "<STR_LIT>" , ( <NUM_LIT:2> , ) ) <EOL> data = c . fetchall ( ) <EOL> self . assertEquals ( <NUM_LIT:2> , len ( data ) ) <EOL> self . assertEquals ( <NUM_LIT:2> , len ( c . description ) ) <EOL> assert c . nextset ( ) is not None , "<STR_LIT>" <EOL> data = c . fetchall ( ) <EOL> self . assertEquals ( <NUM_LIT:1> , len ( data ) ) <EOL> self . assertEquals ( <NUM_LIT:1> , len ( c . description ) ) <EOL> finally : <EOL> c . close ( ) </s>
