<s> """<STR_LIT>""" <EOL> import cx_Oracle <EOL> import decimal <EOL> class TestNumberVar ( BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> BaseTestCase . setUp ( self ) <EOL> self . rawData = [ ] <EOL> self . dataByKey = { } <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:11> ) : <EOL> numberCol = i + i * <NUM_LIT> <EOL> floatCol = i + i * <NUM_LIT> <EOL> unconstrainedCol = i ** <NUM_LIT:3> + i * <NUM_LIT:0.5> <EOL> if i % <NUM_LIT:2> : <EOL> nullableCol = <NUM_LIT> L ** i <EOL> else : <EOL> nullableCol = None <EOL> dataTuple = ( i , numberCol , floatCol , unconstrainedCol , nullableCol ) <EOL> self . rawData . append ( dataTuple ) <EOL> self . dataByKey [ i ] = dataTuple <EOL> def testBindDecimal ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value1 = decimal . Decimal ( "<STR_LIT>" ) , <EOL> value2 = decimal . Decimal ( "<STR_LIT>" ) ) <EOL> self . failUnlessEqual ( self . cursor . fetchall ( ) , <EOL> [ self . dataByKey [ <NUM_LIT:1> ] , self . dataByKey [ <NUM_LIT:5> ] , self . dataByKey [ <NUM_LIT:9> ] ] ) <EOL> def testBindFloat ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value = <NUM_LIT> ) <EOL> self . failUnlessEqual ( self . cursor . fetchall ( ) , <EOL> [ self . dataByKey [ <NUM_LIT:1> ] , self . dataByKey [ <NUM_LIT:5> ] , self . dataByKey [ <NUM_LIT:9> ] ] ) <EOL> def testBindInteger ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value = <NUM_LIT:2> ) <EOL> self . failUnlessEqual ( self . cursor . fetchall ( ) , [ self . dataByKey [ <NUM_LIT:2> ] ] ) <EOL> def testBindSmallLong ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value = <NUM_LIT:3> L ) <EOL> self . failUnlessEqual ( self . cursor . fetchall ( ) , [ self . dataByKey [ <NUM_LIT:3> ] ] ) <EOL> def testBindLargeLong ( self ) : <EOL> "<STR_LIT>" <EOL> valueVar = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> valueVar . setvalue ( <NUM_LIT:0> , <NUM_LIT> ) <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value = valueVar ) <EOL> value = valueVar . getvalue ( ) <EOL> self . failUnlessEqual ( value , <NUM_LIT> ) <EOL> def testBindIntegerAfterString ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . setinputsizes ( value = <NUM_LIT:15> ) <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value = <NUM_LIT:3> ) <EOL> self . failUnlessEqual ( self . cursor . fetchall ( ) , [ self . dataByKey [ <NUM_LIT:3> ] ] ) <EOL> def testBindNull ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value = None ) <EOL> self . failUnlessEqual ( self . cursor . fetchall ( ) , [ ] ) <EOL> def testBindNumberArrayDirect ( self ) : <EOL> "<STR_LIT>" <EOL> returnValue = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> array = [ r [ <NUM_LIT:1> ] for r in self . rawData ] <EOL> statement = """<STR_LIT>""" <EOL> self . cursor . execute ( statement , <EOL> p_ReturnValue = returnValue , <EOL> p_StartValue = <NUM_LIT:5> , <EOL> p_Array = array ) <EOL> self . failUnlessEqual ( returnValue . getvalue ( ) , <NUM_LIT> ) <EOL> array = range ( <NUM_LIT:15> ) <EOL> self . cursor . execute ( statement , <EOL> p_StartValue = <NUM_LIT:10> , <EOL> p_Array = array ) <EOL> self . failUnlessEqual ( returnValue . getvalue ( ) , <NUM_LIT> ) <EOL> def testBindNumberArrayBySizes ( self ) : <EOL> "<STR_LIT>" <EOL> returnValue = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> self . cursor . setinputsizes ( p_Array = [ cx_Oracle . NUMBER , <NUM_LIT:10> ] ) <EOL> array = [ r [ <NUM_LIT:1> ] for r in self . rawData ] <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> p_ReturnValue = returnValue , <EOL> p_StartValue = <NUM_LIT:6> , <EOL> p_Array = array ) <EOL> self . failUnlessEqual ( returnValue . getvalue ( ) , <NUM_LIT> ) <EOL> def testBindNumberArrayByVar ( self ) : <EOL> "<STR_LIT>" <EOL> returnValue = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> array = self . cursor . arrayvar ( cx_Oracle . NUMBER , <EOL> [ r [ <NUM_LIT:1> ] for r in self . rawData ] ) <EOL> array . setvalue ( <NUM_LIT:0> , [ r [ <NUM_LIT:1> ] for r in self . rawData ] ) <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> p_ReturnValue = returnValue , <EOL> p_IntegerValue = <NUM_LIT:7> , <EOL> p_Array = array ) <EOL> self . failUnlessEqual ( returnValue . getvalue ( ) , <NUM_LIT> ) <EOL> def testBindZeroLengthNumberArrayByVar ( self ) : <EOL> "<STR_LIT>" <EOL> returnValue = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> array = self . cursor . arrayvar ( cx_Oracle . NUMBER , <NUM_LIT:0> ) <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> p_ReturnValue = returnValue , <EOL> p_IntegerValue = <NUM_LIT:8> , <EOL> p_Array = array ) <EOL> self . failUnlessEqual ( returnValue . getvalue ( ) , <NUM_LIT> ) <EOL> self . failUnlessEqual ( array . getvalue ( ) , [ ] ) <EOL> def testBindInOutNumberArrayByVar ( self ) : <EOL> "<STR_LIT>" <EOL> array = self . cursor . arrayvar ( cx_Oracle . NUMBER , <NUM_LIT:10> ) <EOL> originalData = [ r [ <NUM_LIT:1> ] for r in self . rawData ] <EOL> expectedData = [ originalData [ i - <NUM_LIT:1> ] * <NUM_LIT:10> for i in range ( <NUM_LIT:1> , <NUM_LIT:6> ) ] + originalData [ <NUM_LIT:5> : ] <EOL> array . setvalue ( <NUM_LIT:0> , originalData ) <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> p_NumElems = <NUM_LIT:5> , <EOL> p_Array = array ) <EOL> self . failUnlessEqual ( array . getvalue ( ) , expectedData ) <EOL> def testBindOutNumberArrayByVar ( self ) : <EOL> "<STR_LIT>" <EOL> array = self . cursor . arrayvar ( cx_Oracle . NUMBER , <NUM_LIT:6> ) <EOL> expectedData = [ i * <NUM_LIT:100> for i in range ( <NUM_LIT:1> , <NUM_LIT:7> ) ] <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> p_NumElems = <NUM_LIT:6> , <EOL> p_Array = array ) <EOL> self . failUnlessEqual ( array . getvalue ( ) , expectedData ) <EOL> def testBindOutSetInputSizes ( self ) : <EOL> "<STR_LIT>" <EOL> vars = self . cursor . setinputsizes ( value = cx_Oracle . NUMBER ) <EOL> self . cursor . execute ( """<STR_LIT>""" ) <EOL> self . failUnlessEqual ( vars [ "<STR_LIT:value>" ] . getvalue ( ) , <NUM_LIT:5> ) <EOL> def testBindInOutSetInputSizes ( self ) : <EOL> "<STR_LIT>" <EOL> vars = self . cursor . setinputsizes ( value = cx_Oracle . NUMBER ) <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value = <NUM_LIT> ) <EOL> self . failUnlessEqual ( vars [ "<STR_LIT:value>" ] . getvalue ( ) , <NUM_LIT> ) <EOL> def testBindOutVar ( self ) : <EOL> "<STR_LIT>" <EOL> var = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value = var ) <EOL> self . failUnlessEqual ( var . getvalue ( ) , <NUM_LIT:5> ) <EOL> def testBindInOutVarDirectSet ( self ) : <EOL> "<STR_LIT>" <EOL> var = self . cursor . var ( cx_Oracle . NUMBER ) <EOL> var . setvalue ( <NUM_LIT:0> , <NUM_LIT> ) <EOL> self . cursor . execute ( """<STR_LIT>""" , <EOL> value = var ) <EOL> self . failUnlessEqual ( var . getvalue ( ) , <NUM_LIT> ) <EOL> def testCursorDescription ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> self . failUnlessEqual ( self . cursor . description , <EOL> [ ( '<STR_LIT>' , cx_Oracle . NUMBER , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , cx_Oracle . NUMBER , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , cx_Oracle . NUMBER , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , cx_Oracle . NUMBER , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , - <NUM_LIT> , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , cx_Oracle . NUMBER , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1> ) ] ) <EOL> def testFetchAll ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> self . failUnlessEqual ( self . cursor . fetchall ( ) , self . rawData ) <EOL> self . failUnlessEqual ( self . cursor . fetchall ( ) , [ ] ) <EOL> def testFetchMany ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> self . failUnlessEqual ( self . cursor . fetchmany ( <NUM_LIT:3> ) , self . rawData [ <NUM_LIT:0> : <NUM_LIT:3> ] ) <EOL> self . failUnlessEqual ( self . cursor . fetchmany ( <NUM_LIT:2> ) , self . rawData [ <NUM_LIT:3> : <NUM_LIT:5> ] ) <EOL> self . failUnlessEqual ( self . cursor . fetchmany ( <NUM_LIT:4> ) , self . rawData [ <NUM_LIT:5> : <NUM_LIT:9> ] ) <EOL> self . failUnlessEqual ( self . cursor . fetchmany ( <NUM_LIT:3> ) , self . rawData [ <NUM_LIT:9> : ] ) <EOL> self . failUnlessEqual ( self . cursor . fetchmany ( <NUM_LIT:3> ) , [ ] ) <EOL> def testFetchOne ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( """<STR_LIT>""" ) <EOL> self . failUnlessEqual ( self . cursor . fetchone ( ) , self . dataByKey [ <NUM_LIT:3> ] ) <EOL> self . failUnlessEqual ( self . cursor . fetchone ( ) , self . dataByKey [ <NUM_LIT:4> ] ) <EOL> self . failUnlessEqual ( self . cursor . fetchone ( ) , None ) <EOL> def testReturnAsLong ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( """<STR_LIT>""" ) <EOL> col , = self . cursor . fetchone ( ) <EOL> self . failUnless ( isinstance ( col , long ) , "<STR_LIT>" ) <EOL> def testReturnAsFloat ( self ) : <EOL> "<STR_LIT>" <EOL> self . cursor . execute ( "<STR_LIT>" ) <EOL> result , = self . cursor . fetchone ( ) <EOL> self . failUnlessEqual ( result , <NUM_LIT> ) </s>
