<s> import unittest <EOL> import sys <EOL> import threading <EOL> import pysqlite2 . dbapi2 as sqlite <EOL> class Seq ( object ) : <EOL> def __len__ ( self ) : <EOL> return <NUM_LIT:1> <EOL> def __getitem__ ( self , x ) : <EOL> if x != <NUM_LIT:0> : <EOL> raise StopIteration <EOL> return "<STR_LIT:foo>" <EOL> class D ( dict ) : <EOL> def __missing__ ( self , key ) : <EOL> return "<STR_LIT:foo>" <EOL> class ModuleTests ( unittest . TestCase ) : <EOL> def CheckAPILevel ( self ) : <EOL> self . assertEqual ( sqlite . apilevel , "<STR_LIT>" , <EOL> "<STR_LIT>" % sqlite . apilevel ) <EOL> def CheckThreadSafety ( self ) : <EOL> self . assertEqual ( sqlite . threadsafety , <NUM_LIT:1> , <EOL> "<STR_LIT>" % sqlite . threadsafety ) <EOL> def CheckParamStyle ( self ) : <EOL> self . assertEqual ( sqlite . paramstyle , "<STR_LIT>" , <EOL> "<STR_LIT>" % <EOL> sqlite . paramstyle ) <EOL> def CheckWarning ( self ) : <EOL> self . assert_ ( issubclass ( sqlite . Warning , StandardError ) , <EOL> "<STR_LIT>" ) <EOL> def CheckError ( self ) : <EOL> self . failUnless ( issubclass ( sqlite . Error , StandardError ) , <EOL> "<STR_LIT>" ) <EOL> def CheckInterfaceError ( self ) : <EOL> self . failUnless ( issubclass ( sqlite . InterfaceError , sqlite . Error ) , <EOL> "<STR_LIT>" ) <EOL> def CheckDatabaseError ( self ) : <EOL> self . failUnless ( issubclass ( sqlite . DatabaseError , sqlite . Error ) , <EOL> "<STR_LIT>" ) <EOL> def CheckDataError ( self ) : <EOL> self . failUnless ( issubclass ( sqlite . DataError , sqlite . DatabaseError ) , <EOL> "<STR_LIT>" ) <EOL> def CheckOperationalError ( self ) : <EOL> self . failUnless ( issubclass ( sqlite . OperationalError , sqlite . DatabaseError ) , <EOL> "<STR_LIT>" ) <EOL> def CheckIntegrityError ( self ) : <EOL> self . failUnless ( issubclass ( sqlite . IntegrityError , sqlite . DatabaseError ) , <EOL> "<STR_LIT>" ) <EOL> def CheckInternalError ( self ) : <EOL> self . failUnless ( issubclass ( sqlite . InternalError , sqlite . DatabaseError ) , <EOL> "<STR_LIT>" ) <EOL> def CheckProgrammingError ( self ) : <EOL> self . failUnless ( issubclass ( sqlite . ProgrammingError , sqlite . DatabaseError ) , <EOL> "<STR_LIT>" ) <EOL> def CheckNotSupportedError ( self ) : <EOL> self . failUnless ( issubclass ( sqlite . NotSupportedError , <EOL> sqlite . DatabaseError ) , <EOL> "<STR_LIT>" ) <EOL> class ConnectionTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . cx = sqlite . connect ( "<STR_LIT>" ) <EOL> cu = self . cx . cursor ( ) <EOL> cu . execute ( "<STR_LIT>" ) <EOL> cu . execute ( "<STR_LIT>" , ( "<STR_LIT:foo>" , ) ) <EOL> def tearDown ( self ) : <EOL> self . cx . close ( ) <EOL> def ACheckCommit ( self ) : <EOL> self . cx . commit ( ) <EOL> def CheckCommitAfterNoChanges ( self ) : <EOL> """<STR_LIT>""" <EOL> return <EOL> self . cx . commit ( ) <EOL> self . cx . commit ( ) <EOL> def CheckRollback ( self ) : <EOL> self . cx . rollback ( ) <EOL> def CheckRollbackAfterNoChanges ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cx . rollback ( ) <EOL> self . cx . rollback ( ) <EOL> def CheckCursor ( self ) : <EOL> cu = self . cx . cursor ( ) <EOL> def CheckFailedOpen ( self ) : <EOL> YOU_CANNOT_OPEN_THIS = "<STR_LIT>" <EOL> try : <EOL> con = sqlite . connect ( YOU_CANNOT_OPEN_THIS ) <EOL> except sqlite . OperationalError : <EOL> return <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckClose ( self ) : <EOL> self . cx . close ( ) <EOL> def CheckExceptions ( self ) : <EOL> self . failUnlessEqual ( self . cx . Warning , sqlite . Warning ) <EOL> self . failUnlessEqual ( self . cx . Error , sqlite . Error ) <EOL> self . failUnlessEqual ( self . cx . InterfaceError , sqlite . InterfaceError ) <EOL> self . failUnlessEqual ( self . cx . DatabaseError , sqlite . DatabaseError ) <EOL> self . failUnlessEqual ( self . cx . DataError , sqlite . DataError ) <EOL> self . failUnlessEqual ( self . cx . OperationalError , sqlite . OperationalError ) <EOL> self . failUnlessEqual ( self . cx . IntegrityError , sqlite . IntegrityError ) <EOL> self . failUnlessEqual ( self . cx . InternalError , sqlite . InternalError ) <EOL> self . failUnlessEqual ( self . cx . ProgrammingError , sqlite . ProgrammingError ) <EOL> self . failUnlessEqual ( self . cx . NotSupportedError , sqlite . NotSupportedError ) <EOL> class CursorTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . cx = sqlite . connect ( "<STR_LIT>" ) <EOL> self . cu = self . cx . cursor ( ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" , ( "<STR_LIT:foo>" , ) ) <EOL> def tearDown ( self ) : <EOL> self . cu . close ( ) <EOL> self . cx . close ( ) <EOL> def CheckExecuteNoArgs ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> def CheckExecuteIllegalSql ( self ) : <EOL> try : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . OperationalError : <EOL> return <EOL> except Exception , e : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckExecuteTooMuchSql ( self ) : <EOL> try : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . Warning : <EOL> return <EOL> except Exception , e : <EOL> print "<STR_LIT:->" * <NUM_LIT:50> <EOL> print "<STR_LIT:->" * <NUM_LIT:50> <EOL> print e <EOL> print "<STR_LIT:->" * <NUM_LIT:50> <EOL> print "<STR_LIT:->" * <NUM_LIT:50> <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckExecuteTooMuchSql2 ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> def CheckExecuteTooMuchSql3 ( self ) : <EOL> self . cu . execute ( """<STR_LIT>""" ) <EOL> def CheckExecuteWrongSqlArg ( self ) : <EOL> try : <EOL> self . cu . execute ( <NUM_LIT> ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except ValueError : <EOL> return <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckExecuteArgInt ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" , ( <NUM_LIT> , ) ) <EOL> def CheckExecuteArgFloat ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" , ( <NUM_LIT> , ) ) <EOL> def CheckExecuteArgString ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" , ( "<STR_LIT>" , ) ) <EOL> def CheckExecuteArgStringSubclass ( self ) : <EOL> class S ( str ) : <EOL> pass <EOL> self . cu . execute ( "<STR_LIT>" , ( S ( "<STR_LIT>" ) , ) ) <EOL> def CheckExecuteArgUnicode ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" , ( u"<STR_LIT>" , ) ) <EOL> def CheckExecuteArgUnicodeSubclass ( self ) : <EOL> class U ( unicode ) : <EOL> pass <EOL> self . cu . execute ( "<STR_LIT>" , ( U ( "<STR_LIT>" ) , ) ) <EOL> def CheckExecuteWrongNoOfArgs1 ( self ) : <EOL> try : <EOL> self . cu . execute ( "<STR_LIT>" , ( <NUM_LIT> , "<STR_LIT>" ) ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> def CheckExecuteWrongNoOfArgs2 ( self ) : <EOL> try : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> def CheckExecuteWrongNoOfArgs3 ( self ) : <EOL> try : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> def CheckExecuteParamList ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" , [ "<STR_LIT:foo>" ] ) <EOL> row = self . cu . fetchone ( ) <EOL> self . failUnlessEqual ( row [ <NUM_LIT:0> ] , "<STR_LIT:foo>" ) <EOL> def CheckExecuteParamSequence ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" , Seq ( ) ) <EOL> row = self . cu . fetchone ( ) <EOL> self . failUnlessEqual ( row [ <NUM_LIT:0> ] , "<STR_LIT:foo>" ) <EOL> def CheckExecuteDictMapping ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" , { "<STR_LIT:name>" : "<STR_LIT:foo>" } ) <EOL> row = self . cu . fetchone ( ) <EOL> self . failUnlessEqual ( row [ <NUM_LIT:0> ] , "<STR_LIT:foo>" ) <EOL> def CheckExecuteDictMapping_Mapping ( self ) : <EOL> if sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:0> ) : <EOL> return <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" , D ( ) ) <EOL> row = self . cu . fetchone ( ) <EOL> self . failUnlessEqual ( row [ <NUM_LIT:0> ] , "<STR_LIT:foo>" ) <EOL> def CheckExecuteDictMappingTooLittleArgs ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> try : <EOL> self . cu . execute ( "<STR_LIT>" , { "<STR_LIT:name>" : "<STR_LIT:foo>" } ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> def CheckExecuteDictMappingNoArgs ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> try : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> def CheckExecuteDictMappingUnnamed ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> try : <EOL> self . cu . execute ( "<STR_LIT>" , { "<STR_LIT:name>" : "<STR_LIT:foo>" } ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> def CheckClose ( self ) : <EOL> self . cu . close ( ) <EOL> def CheckRowcountExecute ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . failUnlessEqual ( self . cu . rowcount , <NUM_LIT:2> ) <EOL> def CheckRowcountExecutemany ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . executemany ( "<STR_LIT>" , [ ( <NUM_LIT:1> , ) , ( <NUM_LIT:2> , ) , ( <NUM_LIT:3> , ) ] ) <EOL> self . failUnlessEqual ( self . cu . rowcount , <NUM_LIT:3> ) <EOL> def CheckTotalChanges ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> if self . cx . total_changes < <NUM_LIT:2> : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckExecuteManySequence ( self ) : <EOL> self . cu . executemany ( "<STR_LIT>" , [ ( x , ) for x in range ( <NUM_LIT:100> , <NUM_LIT> ) ] ) <EOL> def CheckExecuteManyIterator ( self ) : <EOL> class MyIter : <EOL> def __init__ ( self ) : <EOL> self . value = <NUM_LIT:5> <EOL> def next ( self ) : <EOL> if self . value == <NUM_LIT:10> : <EOL> raise StopIteration <EOL> else : <EOL> self . value += <NUM_LIT:1> <EOL> return ( self . value , ) <EOL> print "<STR_LIT:*>" * <NUM_LIT:50> <EOL> for x in MyIter ( ) : <EOL> print x <EOL> print "<STR_LIT:*>" * <NUM_LIT:50> <EOL> self . cu . executemany ( "<STR_LIT>" , MyIter ( ) ) <EOL> def CheckExecuteManyGenerator ( self ) : <EOL> def mygen ( ) : <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> yield ( i , ) <EOL> self . cu . executemany ( "<STR_LIT>" , mygen ( ) ) <EOL> def CheckExecuteManyWrongSqlArg ( self ) : <EOL> try : <EOL> self . cu . executemany ( <NUM_LIT> , [ ( <NUM_LIT:3> , ) ] ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except ValueError : <EOL> return <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckExecuteManySelect ( self ) : <EOL> try : <EOL> self . cu . executemany ( "<STR_LIT>" , [ ( <NUM_LIT:3> , ) ] ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> return <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckExecuteManyNotIterable ( self ) : <EOL> try : <EOL> self . cu . executemany ( "<STR_LIT>" , <NUM_LIT> ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except TypeError : <EOL> return <EOL> except Exception , e : <EOL> print "<STR_LIT>" , e . __class__ <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckFetchIter ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" , ( <NUM_LIT:5> , ) ) <EOL> self . cu . execute ( "<STR_LIT>" , ( <NUM_LIT:6> , ) ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> lst = [ ] <EOL> for row in self . cu : <EOL> lst . append ( row [ <NUM_LIT:0> ] ) <EOL> self . failUnlessEqual ( lst [ <NUM_LIT:0> ] , <NUM_LIT:5> ) <EOL> self . failUnlessEqual ( lst [ <NUM_LIT:1> ] , <NUM_LIT:6> ) <EOL> def CheckFetchone ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> row = self . cu . fetchone ( ) <EOL> self . failUnlessEqual ( row [ <NUM_LIT:0> ] , "<STR_LIT:foo>" ) <EOL> row = self . cu . fetchone ( ) <EOL> self . failUnlessEqual ( row , None ) <EOL> def CheckFetchoneNoStatement ( self ) : <EOL> cur = self . cx . cursor ( ) <EOL> row = cur . fetchone ( ) <EOL> self . failUnlessEqual ( row , None ) <EOL> def CheckArraySize ( self ) : <EOL> self . failUnlessEqual ( self . cu . arraysize , <NUM_LIT:1> ) <EOL> self . cu . arraysize = <NUM_LIT:2> <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> res = self . cu . fetchmany ( ) <EOL> self . failUnlessEqual ( len ( res ) , <NUM_LIT:2> ) <EOL> def CheckFetchmany ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> res = self . cu . fetchmany ( <NUM_LIT:100> ) <EOL> self . failUnlessEqual ( len ( res ) , <NUM_LIT:1> ) <EOL> res = self . cu . fetchmany ( <NUM_LIT:100> ) <EOL> self . failUnlessEqual ( res , [ ] ) <EOL> def CheckFetchmanyKwArg ( self ) : <EOL> """<STR_LIT>""" <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> res = self . cu . fetchmany ( size = <NUM_LIT:100> ) <EOL> self . failUnlessEqual ( len ( res ) , <NUM_LIT:1> ) <EOL> def CheckFetchall ( self ) : <EOL> self . cu . execute ( "<STR_LIT>" ) <EOL> res = self . cu . fetchall ( ) <EOL> self . failUnlessEqual ( len ( res ) , <NUM_LIT:1> ) <EOL> res = self . cu . fetchall ( ) <EOL> self . failUnlessEqual ( res , [ ] ) <EOL> def CheckSetinputsizes ( self ) : <EOL> self . cu . setinputsizes ( [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> def CheckSetoutputsize ( self ) : <EOL> self . cu . setoutputsize ( <NUM_LIT:5> , <NUM_LIT:0> ) <EOL> def CheckSetoutputsizeNoColumn ( self ) : <EOL> self . cu . setoutputsize ( <NUM_LIT> ) <EOL> def CheckCursorConnection ( self ) : <EOL> self . failUnlessEqual ( self . cu . connection , self . cx ) <EOL> def CheckWrongCursorCallable ( self ) : <EOL> try : <EOL> def f ( ) : pass <EOL> cur = self . cx . cursor ( f ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except TypeError : <EOL> return <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckCursorWrongClass ( self ) : <EOL> class Foo : pass <EOL> foo = Foo ( ) <EOL> try : <EOL> cur = sqlite . Cursor ( foo ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except TypeError : <EOL> pass <EOL> class ThreadTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . con = sqlite . connect ( "<STR_LIT>" ) <EOL> self . cur = self . con . cursor ( ) <EOL> self . cur . execute ( "<STR_LIT>" ) <EOL> def tearDown ( self ) : <EOL> self . cur . close ( ) <EOL> self . con . close ( ) <EOL> def CheckConCursor ( self ) : <EOL> def run ( con , errors ) : <EOL> try : <EOL> cur = con . cursor ( ) <EOL> errors . append ( "<STR_LIT>" ) <EOL> return <EOL> except sqlite . ProgrammingError : <EOL> return <EOL> except : <EOL> errors . append ( "<STR_LIT>" ) <EOL> errors = [ ] <EOL> t = threading . Thread ( target = run , kwargs = { "<STR_LIT>" : self . con , "<STR_LIT>" : errors } ) <EOL> t . start ( ) <EOL> t . join ( ) <EOL> if len ( errors ) > <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT:\n>" . join ( errors ) ) <EOL> def CheckConCommit ( self ) : <EOL> def run ( con , errors ) : <EOL> try : <EOL> con . commit ( ) <EOL> errors . append ( "<STR_LIT>" ) <EOL> return <EOL> except sqlite . ProgrammingError : <EOL> return <EOL> except : <EOL> errors . append ( "<STR_LIT>" ) <EOL> errors = [ ] <EOL> t = threading . Thread ( target = run , kwargs = { "<STR_LIT>" : self . con , "<STR_LIT>" : errors } ) <EOL> t . start ( ) <EOL> t . join ( ) <EOL> if len ( errors ) > <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT:\n>" . join ( errors ) ) <EOL> def CheckConRollback ( self ) : <EOL> def run ( con , errors ) : <EOL> try : <EOL> con . rollback ( ) <EOL> errors . append ( "<STR_LIT>" ) <EOL> return <EOL> except sqlite . ProgrammingError : <EOL> return <EOL> except : <EOL> errors . append ( "<STR_LIT>" ) <EOL> errors = [ ] <EOL> t = threading . Thread ( target = run , kwargs = { "<STR_LIT>" : self . con , "<STR_LIT>" : errors } ) <EOL> t . start ( ) <EOL> t . join ( ) <EOL> if len ( errors ) > <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT:\n>" . join ( errors ) ) <EOL> def CheckConClose ( self ) : <EOL> def run ( con , errors ) : <EOL> try : <EOL> con . close ( ) <EOL> errors . append ( "<STR_LIT>" ) <EOL> return <EOL> except sqlite . ProgrammingError : <EOL> return <EOL> except : <EOL> errors . append ( "<STR_LIT>" ) <EOL> errors = [ ] <EOL> t = threading . Thread ( target = run , kwargs = { "<STR_LIT>" : self . con , "<STR_LIT>" : errors } ) <EOL> t . start ( ) <EOL> t . join ( ) <EOL> if len ( errors ) > <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT:\n>" . join ( errors ) ) <EOL> def CheckCurImplicitBegin ( self ) : <EOL> def run ( cur , errors ) : <EOL> try : <EOL> cur . execute ( "<STR_LIT>" ) <EOL> errors . append ( "<STR_LIT>" ) <EOL> return <EOL> except sqlite . ProgrammingError : <EOL> return <EOL> except : <EOL> errors . append ( "<STR_LIT>" ) <EOL> errors = [ ] <EOL> t = threading . Thread ( target = run , kwargs = { "<STR_LIT>" : self . cur , "<STR_LIT>" : errors } ) <EOL> t . start ( ) <EOL> t . join ( ) <EOL> if len ( errors ) > <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT:\n>" . join ( errors ) ) <EOL> def CheckCurClose ( self ) : <EOL> def run ( cur , errors ) : <EOL> try : <EOL> cur . close ( ) <EOL> errors . append ( "<STR_LIT>" ) <EOL> return <EOL> except sqlite . ProgrammingError : <EOL> return <EOL> except : <EOL> errors . append ( "<STR_LIT>" ) <EOL> errors = [ ] <EOL> t = threading . Thread ( target = run , kwargs = { "<STR_LIT>" : self . cur , "<STR_LIT>" : errors } ) <EOL> t . start ( ) <EOL> t . join ( ) <EOL> if len ( errors ) > <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT:\n>" . join ( errors ) ) <EOL> def CheckCurExecute ( self ) : <EOL> def run ( cur , errors ) : <EOL> try : <EOL> cur . execute ( "<STR_LIT>" ) <EOL> errors . append ( "<STR_LIT>" ) <EOL> return <EOL> except sqlite . ProgrammingError : <EOL> return <EOL> except : <EOL> errors . append ( "<STR_LIT>" ) <EOL> errors = [ ] <EOL> self . cur . execute ( "<STR_LIT>" ) <EOL> t = threading . Thread ( target = run , kwargs = { "<STR_LIT>" : self . cur , "<STR_LIT>" : errors } ) <EOL> t . start ( ) <EOL> t . join ( ) <EOL> if len ( errors ) > <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT:\n>" . join ( errors ) ) <EOL> def CheckCurIterNext ( self ) : <EOL> def run ( cur , errors ) : <EOL> try : <EOL> row = cur . fetchone ( ) <EOL> errors . append ( "<STR_LIT>" ) <EOL> return <EOL> except sqlite . ProgrammingError : <EOL> return <EOL> except : <EOL> errors . append ( "<STR_LIT>" ) <EOL> errors = [ ] <EOL> self . cur . execute ( "<STR_LIT>" ) <EOL> self . cur . execute ( "<STR_LIT>" ) <EOL> t = threading . Thread ( target = run , kwargs = { "<STR_LIT>" : self . cur , "<STR_LIT>" : errors } ) <EOL> t . start ( ) <EOL> t . join ( ) <EOL> if len ( errors ) > <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT:\n>" . join ( errors ) ) <EOL> class ConstructorTests ( unittest . TestCase ) : <EOL> def CheckDate ( self ) : <EOL> d = sqlite . Date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> ) <EOL> def CheckTime ( self ) : <EOL> t = sqlite . Time ( <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ) <EOL> def CheckTimestamp ( self ) : <EOL> ts = sqlite . Timestamp ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> ) <EOL> def CheckDateFromTicks ( self ) : <EOL> d = sqlite . DateFromTicks ( <NUM_LIT> ) <EOL> def CheckTimeFromTicks ( self ) : <EOL> t = sqlite . TimeFromTicks ( <NUM_LIT> ) <EOL> def CheckTimestampFromTicks ( self ) : <EOL> ts = sqlite . TimestampFromTicks ( <NUM_LIT> ) <EOL> def CheckBinary ( self ) : <EOL> b = sqlite . Binary ( chr ( <NUM_LIT:0> ) + "<STR_LIT:'>" ) <EOL> class ExtensionTests ( unittest . TestCase ) : <EOL> def CheckScriptStringSql ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> cur = con . cursor ( ) <EOL> cur . executescript ( """<STR_LIT>""" ) <EOL> cur . execute ( "<STR_LIT>" ) <EOL> res = cur . fetchone ( ) [ <NUM_LIT:0> ] <EOL> self . failUnlessEqual ( res , <NUM_LIT:5> ) <EOL> def CheckScriptStringUnicode ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> cur = con . cursor ( ) <EOL> cur . executescript ( u"""<STR_LIT>""" ) <EOL> cur . execute ( "<STR_LIT>" ) <EOL> res = cur . fetchone ( ) [ <NUM_LIT:0> ] <EOL> self . failUnlessEqual ( res , <NUM_LIT:6> ) <EOL> def CheckScriptErrorIncomplete ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> cur = con . cursor ( ) <EOL> raised = False <EOL> try : <EOL> cur . executescript ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> raised = True <EOL> self . failUnlessEqual ( raised , True , "<STR_LIT>" ) <EOL> def CheckScriptErrorNormal ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> cur = con . cursor ( ) <EOL> raised = False <EOL> try : <EOL> cur . executescript ( "<STR_LIT>" ) <EOL> except sqlite . OperationalError : <EOL> raised = True <EOL> self . failUnlessEqual ( raised , True , "<STR_LIT>" ) <EOL> def CheckConnectionExecute ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> result = con . execute ( "<STR_LIT>" ) . fetchone ( ) [ <NUM_LIT:0> ] <EOL> self . failUnlessEqual ( result , <NUM_LIT:5> , "<STR_LIT>" ) <EOL> def CheckConnectionExecutemany ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> con . execute ( "<STR_LIT>" ) <EOL> con . executemany ( "<STR_LIT>" , [ ( <NUM_LIT:3> , ) , ( <NUM_LIT:4> , ) ] ) <EOL> result = con . execute ( "<STR_LIT>" ) . fetchall ( ) <EOL> self . failUnlessEqual ( result [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT:3> , "<STR_LIT>" ) <EOL> self . failUnlessEqual ( result [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , <NUM_LIT:4> , "<STR_LIT>" ) <EOL> def CheckConnectionExecutescript ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> con . executescript ( "<STR_LIT>" ) <EOL> result = con . execute ( "<STR_LIT>" ) . fetchone ( ) [ <NUM_LIT:0> ] <EOL> self . failUnlessEqual ( result , <NUM_LIT:5> , "<STR_LIT>" ) <EOL> class ClosedTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> pass <EOL> def tearDown ( self ) : <EOL> pass <EOL> def CheckClosedConCursor ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> con . close ( ) <EOL> try : <EOL> cur = con . cursor ( ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckClosedConCommit ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> con . close ( ) <EOL> try : <EOL> con . commit ( ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckClosedConRollback ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> con . close ( ) <EOL> try : <EOL> con . rollback ( ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def CheckClosedCurExecute ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> cur = con . cursor ( ) <EOL> con . close ( ) <EOL> try : <EOL> cur . execute ( "<STR_LIT>" ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except sqlite . ProgrammingError : <EOL> pass <EOL> except : <EOL> self . fail ( "<STR_LIT>" ) <EOL> class BugTests ( unittest . TestCase ) : <EOL> def CheckOpenCursor ( self ) : <EOL> con = sqlite . connect ( "<STR_LIT>" ) <EOL> con . execute ( """<STR_LIT>""" ) <EOL> con . execute ( "<STR_LIT>" ) <EOL> con . commit ( ) <EOL> cur1 = con . execute ( "<STR_LIT>" ) <EOL> res = iter ( cur1 ) . next ( ) <EOL> assert res == ( <NUM_LIT:1> , ) <EOL> con . execute ( "<STR_LIT>" ) <EOL> con . commit ( ) <EOL> cur1 = con . execute ( "<STR_LIT>" ) <EOL> res = iter ( cur1 ) . next ( ) <EOL> assert res == ( <NUM_LIT:2> , ) <EOL> def suite ( ) : <EOL> module_suite = unittest . makeSuite ( ModuleTests , "<STR_LIT>" ) <EOL> connection_suite = unittest . makeSuite ( ConnectionTests , "<STR_LIT>" ) <EOL> cursor_suite = unittest . makeSuite ( CursorTests , "<STR_LIT>" ) <EOL> thread_suite = unittest . makeSuite ( ThreadTests , "<STR_LIT>" ) <EOL> constructor_suite = unittest . makeSuite ( ConstructorTests , "<STR_LIT>" ) <EOL> ext_suite = unittest . makeSuite ( ExtensionTests , "<STR_LIT>" ) <EOL> closed_suite = unittest . makeSuite ( ClosedTests , "<STR_LIT>" ) <EOL> bug_suite = unittest . makeSuite ( BugTests , "<STR_LIT>" ) <EOL> return unittest . TestSuite ( ( module_suite , connection_suite , cursor_suite , thread_suite , constructor_suite , ext_suite , closed_suite , bug_suite ) ) <EOL> def test ( ) : <EOL> runner = unittest . TextTestRunner ( ) <EOL> runner . run ( suite ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test ( ) </s>
