#NEWLINE# def run_in_both( cls , reference , extra_classes = ( ) ) : #NEWLINE# #INDENT# ' The test decorator.\n    ' #NEWLINE# if ( reference . lower ( ) != reference ) : #NEWLINE# #INDENT# raise ValueError ( 'Test reference should be lowercase!' ) #NEWLINE# #UNINDENT# def wrapper( func ) : #NEWLINE# #INDENT# def runner( ) : #NEWLINE# #INDENT# code = HasEventsJS . JSCODE #NEWLINE# for c in cls . mro ( ) [ 1 : ] : #NEWLINE# #INDENT# if ( c is event . HasEvents ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# code += create_js_hasevents_class ( c , c . __name__ , ( c . __bases__ [ 0 ] . __name__ + '.prototype' ) ) #NEWLINE# #UNINDENT# for c in extra_classes : #NEWLINE# #INDENT# code += create_js_hasevents_class ( c , c . __name__ ) #NEWLINE# #UNINDENT# code += create_js_hasevents_class ( cls , cls . __name__ , ( cls . __bases__ [ 0 ] . __name__ + '.prototype' ) ) #NEWLINE# code += py2js ( func , 'test' , inline_stdlib = False ) #NEWLINE# code += ( 'test(%s);' % cls . __name__ ) #NEWLINE# ( nargs , function_deps , method_deps ) = get_std_info ( code ) #NEWLINE# code = ( get_partial_std_lib ( function_deps , method_deps , [ ] ) + code ) #NEWLINE# code = reduce_code ( code ) #NEWLINE# jsresult = evaljs ( code ) #NEWLINE# jsresult = jsresult . replace ( '[ ' , '[' ) . replace ( ' ]' , ']' ) . replace ( '\n  ' , ' ' ) #NEWLINE# jsresult = jsresult . replace ( '"' , "'" ) . split ( '!!!!' ) [ ( - 1 ) ] #NEWLINE# print ( 'js:' , jsresult ) #NEWLINE# pyresult = reprs ( func ( cls ) ) #NEWLINE# pyresult = pyresult . replace ( '"' , "'" ) . replace ( "\\'" , "'" ) . split ( '!!!!' ) [ ( - 1 ) ] #NEWLINE# print ( 'py:' , pyresult ) #NEWLINE# assert ( pyresult . lower ( ) == reference ) #NEWLINE# assert ( jsresult . lower ( ) == reference ) #NEWLINE# #UNINDENT# return runner #NEWLINE# #UNINDENT# return wrapper