<s> """<STR_LIT>""" <EOL> from io import BytesIO <EOL> from xml . dom import minidom as dom <EOL> from twisted . internet . protocol import FileWrapper <EOL> class IOPump : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , client , server , clientIO , serverIO ) : <EOL> self . client = client <EOL> self . server = server <EOL> self . clientIO = clientIO <EOL> self . serverIO = serverIO <EOL> def flush ( self ) : <EOL> "<STR_LIT>" <EOL> while self . pump ( ) : <EOL> pass <EOL> def pump ( self ) : <EOL> """<STR_LIT>""" <EOL> self . clientIO . seek ( <NUM_LIT:0> ) <EOL> self . serverIO . seek ( <NUM_LIT:0> ) <EOL> cData = self . clientIO . read ( ) <EOL> sData = self . serverIO . read ( ) <EOL> self . clientIO . seek ( <NUM_LIT:0> ) <EOL> self . serverIO . seek ( <NUM_LIT:0> ) <EOL> self . clientIO . truncate ( ) <EOL> self . serverIO . truncate ( ) <EOL> for byte in cData : <EOL> self . server . dataReceived ( byte ) <EOL> for byte in sData : <EOL> self . client . dataReceived ( byte ) <EOL> if cData or sData : <EOL> return <NUM_LIT:1> <EOL> else : <EOL> return <NUM_LIT:0> <EOL> def returnConnected ( server , client ) : <EOL> """<STR_LIT>""" <EOL> cio = BytesIO ( ) <EOL> sio = BytesIO ( ) <EOL> client . makeConnection ( FileWrapper ( cio ) ) <EOL> server . makeConnection ( FileWrapper ( sio ) ) <EOL> pump = IOPump ( client , server , cio , sio ) <EOL> pump . flush ( ) <EOL> pump . flush ( ) <EOL> return pump <EOL> class XMLAssertionMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> def assertXMLEqual ( self , first , second ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> dom . parseString ( first ) . toxml ( ) , <EOL> dom . parseString ( second ) . toxml ( ) ) <EOL> class _Equal ( object ) : <EOL> """<STR_LIT>""" <EOL> def __eq__ ( self , other ) : <EOL> return True <EOL> def __ne__ ( self , other ) : <EOL> return False <EOL> class _NotEqual ( object ) : <EOL> """<STR_LIT>""" <EOL> def __eq__ ( self , other ) : <EOL> return False <EOL> def __ne__ ( self , other ) : <EOL> return True <EOL> class ComparisonTestsMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> def assertNormalEqualityImplementation ( self , firstValueOne , secondValueOne , <EOL> valueTwo ) : <EOL> """<STR_LIT>""" <EOL> self . assertTrue ( firstValueOne == firstValueOne ) <EOL> self . assertTrue ( firstValueOne == secondValueOne ) <EOL> self . assertFalse ( firstValueOne == valueTwo ) <EOL> self . assertFalse ( firstValueOne != firstValueOne ) <EOL> self . assertFalse ( firstValueOne != secondValueOne ) <EOL> self . assertTrue ( firstValueOne != valueTwo ) <EOL> self . assertTrue ( firstValueOne == _Equal ( ) ) <EOL> self . assertFalse ( firstValueOne != _Equal ( ) ) <EOL> self . assertFalse ( firstValueOne == _NotEqual ( ) ) <EOL> self . assertTrue ( firstValueOne != _NotEqual ( ) ) </s>
