<s> """<STR_LIT>""" <EOL> import unittest <EOL> from test . support import run_unittest , is_jython <EOL> from codeop import compile_command , PyCF_DONT_IMPLY_DEDENT <EOL> import io <EOL> if is_jython : <EOL> import sys <EOL> def unify_callables ( d ) : <EOL> for n , v in d . items ( ) : <EOL> if hasattr ( v , '<STR_LIT>' ) : <EOL> d [ n ] = True <EOL> return d <EOL> class CodeopTests ( unittest . TestCase ) : <EOL> def assertValid ( self , str , symbol = '<STR_LIT>' ) : <EOL> '''<STR_LIT>''' <EOL> if is_jython : <EOL> code = compile_command ( str , "<STR_LIT>" , symbol ) <EOL> self . assertTrue ( code ) <EOL> if symbol == "<STR_LIT>" : <EOL> d , r = { } , { } <EOL> saved_stdout = sys . stdout <EOL> sys . stdout = io . StringIO ( ) <EOL> try : <EOL> exec ( code , d ) <EOL> exec ( compile ( str , "<STR_LIT>" , "<STR_LIT>" ) , r ) <EOL> finally : <EOL> sys . stdout = saved_stdout <EOL> elif symbol == '<STR_LIT>' : <EOL> ctx = { '<STR_LIT:a>' : <NUM_LIT:2> } <EOL> d = { '<STR_LIT:value>' : eval ( code , ctx ) } <EOL> r = { '<STR_LIT:value>' : eval ( str , ctx ) } <EOL> self . assertEqual ( unify_callables ( r ) , unify_callables ( d ) ) <EOL> else : <EOL> expected = compile ( str , "<STR_LIT>" , symbol , PyCF_DONT_IMPLY_DEDENT ) <EOL> self . assertEqual ( compile_command ( str , "<STR_LIT>" , symbol ) , expected ) <EOL> def assertIncomplete ( self , str , symbol = '<STR_LIT>' ) : <EOL> '''<STR_LIT>''' <EOL> self . assertEqual ( compile_command ( str , symbol = symbol ) , None ) <EOL> def assertInvalid ( self , str , symbol = '<STR_LIT>' , is_syntax = <NUM_LIT:1> ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> compile_command ( str , symbol = symbol ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except SyntaxError : <EOL> self . assertTrue ( is_syntax ) <EOL> except OverflowError : <EOL> self . assertTrue ( not is_syntax ) <EOL> def test_valid ( self ) : <EOL> av = self . assertValid <EOL> if not is_jython : <EOL> self . assertEqual ( compile_command ( "<STR_LIT>" ) , <EOL> compile ( "<STR_LIT>" , "<STR_LIT>" , '<STR_LIT>' , <EOL> PyCF_DONT_IMPLY_DEDENT ) ) <EOL> self . assertEqual ( compile_command ( "<STR_LIT:\n>" ) , <EOL> compile ( "<STR_LIT>" , "<STR_LIT>" , '<STR_LIT>' , <EOL> PyCF_DONT_IMPLY_DEDENT ) ) <EOL> else : <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT:\n>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> av ( "<STR_LIT>" ) <EOL> def test_incomplete ( self ) : <EOL> ai = self . assertIncomplete <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT:\n>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT:(>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT:[>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT:{>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) ; <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT:(>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> def test_invalid ( self ) : <EOL> ai = self . assertInvalid <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT:]>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> ai ( "<STR_LIT>" ) <EOL> def test_filename ( self ) : <EOL> self . assertEqual ( compile_command ( "<STR_LIT>" , "<STR_LIT:abc>" ) . co_filename , <EOL> compile ( "<STR_LIT>" , "<STR_LIT:abc>" , '<STR_LIT>' ) . co_filename ) <EOL> self . assertNotEqual ( compile_command ( "<STR_LIT>" , "<STR_LIT:abc>" ) . co_filename , <EOL> compile ( "<STR_LIT>" , "<STR_LIT>" , '<STR_LIT>' ) . co_filename ) <EOL> def test_main ( ) : <EOL> run_unittest ( CodeopTests ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
