<s> from client . sources . common import interpreter <EOL> from client . sources . common import pyconsole <EOL> from client . utils import locking <EOL> import client <EOL> import unittest <EOL> class PythonConsoleTest ( unittest . TestCase ) : <EOL> def createConsole ( self , verbose = True , interactive = False , timeout = None ) : <EOL> return pyconsole . PythonConsole ( <EOL> verbose , interactive , timeout ) <EOL> def calls_interpret ( self , success , code , setup = '<STR_LIT>' , teardown = '<STR_LIT>' , skip_locked_cases = True , hash_key = None ) : <EOL> self . console = self . createConsole ( ) <EOL> self . console . skip_locked_cases = skip_locked_cases <EOL> self . console . hash_key = hash_key <EOL> lines = interpreter . CodeCase . split_code ( code , self . console . PS1 , <EOL> self . console . PS2 ) <EOL> self . console . load ( lines , setup , teardown ) <EOL> result = self . console . interpret ( ) <EOL> self . assertEqual ( success , result ) <EOL> def testPass_equals ( self ) : <EOL> self . calls_interpret ( True , <EOL> """<STR_LIT>""" ) <EOL> def testPass_expectException ( self ) : <EOL> self . calls_interpret ( True , <EOL> """<STR_LIT>""" ) <EOL> def testPass_multilineSinglePrompt ( self ) : <EOL> self . calls_interpret ( True , <EOL> """<STR_LIT>""" ) <EOL> def testPass_multiplePrompts ( self ) : <EOL> self . calls_interpret ( True , <EOL> """<STR_LIT>""" ) <EOL> def testPass_multilineWithIndentation ( self ) : <EOL> self . calls_interpret ( True , <EOL> """<STR_LIT>""" ) <EOL> def testPass_setup ( self ) : <EOL> self . calls_interpret ( True , <EOL> """<STR_LIT>""" , <EOL> setup = """<STR_LIT>""" ) <EOL> def testPass_teardown ( self ) : <EOL> self . calls_interpret ( True , <EOL> """<STR_LIT>""" , <EOL> teardown = """<STR_LIT>""" ) <EOL> self . assertEqual ( <NUM_LIT:1> , client . foo ) <EOL> def testError_notEqualError ( self ) : <EOL> self . calls_interpret ( False , <EOL> """<STR_LIT>""" ) <EOL> def testError_expectedException ( self ) : <EOL> self . calls_interpret ( False , <EOL> """<STR_LIT>""" ) <EOL> def testError_wrongException ( self ) : <EOL> self . calls_interpret ( False , <EOL> """<STR_LIT>""" ) <EOL> def testError_runtimeError ( self ) : <EOL> self . calls_interpret ( False , <EOL> """<STR_LIT>""" ) <EOL> def testError_timeoutError ( self ) : <EOL> pass <EOL> def testError_teardown ( self ) : <EOL> self . calls_interpret ( False , <EOL> """<STR_LIT>""" , <EOL> teardown = """<STR_LIT>""" ) <EOL> self . assertEqual ( <NUM_LIT:2> , client . foo ) <EOL> def testError_setUpFails ( self ) : <EOL> self . calls_interpret ( False , <EOL> """<STR_LIT>""" , <EOL> setup = """<STR_LIT>""" , <EOL> teardown = """<STR_LIT>""" ) <EOL> self . assertEqual ( <NUM_LIT:3> , client . foo ) <EOL> def testError_tearDownFails ( self ) : <EOL> self . calls_interpret ( False , <EOL> """<STR_LIT>""" , <EOL> teardown = """<STR_LIT>""" ) <EOL> def testPass_locked ( self ) : <EOL> key = "<STR_LIT>" <EOL> hashedAnswer = locking . lock ( key , "<STR_LIT:4>" ) <EOL> self . calls_interpret ( True , """<STR_LIT>""" % hashedAnswer , skip_locked_cases = False , hash_key = key ) <EOL> def testError_locked ( self ) : <EOL> key = "<STR_LIT>" <EOL> hashedAnswer = locking . lock ( key , "<STR_LIT:5>" ) <EOL> self . calls_interpret ( False , """<STR_LIT>""" % hashedAnswer , skip_locked_cases = False , hash_key = key ) <EOL> def testError_skipLocked ( self ) : <EOL> key = "<STR_LIT>" <EOL> hashedAnswer = locking . lock ( key , "<STR_LIT:4>" ) <EOL> self . calls_interpret ( False , """<STR_LIT>""" % hashedAnswer ) </s>
