<s> """<STR_LIT>""" <EOL> try : <EOL> import cython <EOL> no_cython = False <EOL> except ImportError : <EOL> no_cython = True <EOL> from . . testing . unittest_tools import unittest , UnittestTools <EOL> def has_no_compiler ( ) : <EOL> if no_cython : <EOL> return True <EOL> code = "<STR_LIT>" <EOL> try : <EOL> cython . inline ( code ) <EOL> return False <EOL> except : <EOL> return True <EOL> def cython_version ( ) : <EOL> if no_cython : <EOL> return None <EOL> from Cython . Compiler . Version import version <EOL> return tuple ( int ( v ) for v in version . split ( '<STR_LIT:.>' ) ) <EOL> SKIP_TEST = has_no_compiler ( ) <EOL> def _always_object_type ( arg , context ) : <EOL> return '<STR_LIT:object>' <EOL> class CythonizedTraitsTestCase ( unittest . TestCase , UnittestTools ) : <EOL> @ unittest . skipIf ( SKIP_TEST , '<STR_LIT>' ) <EOL> def test_simple_default_methods ( self ) : <EOL> code = """<STR_LIT>""" <EOL> obj = cython . inline ( code ) <EOL> self . assertEqual ( obj . name , '<STR_LIT>' ) <EOL> @ unittest . skipIf ( SKIP_TEST , '<STR_LIT>' ) <EOL> def test_basic_events ( self ) : <EOL> code = """<STR_LIT>""" <EOL> obj = cython . inline ( code ) <EOL> with self . assertTraitChanges ( obj , '<STR_LIT:name>' , count = <NUM_LIT:1> ) : <EOL> obj . name = '<STR_LIT>' <EOL> @ unittest . skipIf ( SKIP_TEST , '<STR_LIT>' ) <EOL> def test_on_trait_static_handlers ( self ) : <EOL> code = """<STR_LIT>""" <EOL> obj = cython . inline ( code , get_type = _always_object_type , force = True ) <EOL> with self . assertTraitChanges ( obj , '<STR_LIT:value>' , count = <NUM_LIT:1> ) : <EOL> obj . name = '<STR_LIT>' <EOL> self . assertEqual ( obj . value , <NUM_LIT:1> ) <EOL> @ unittest . skipIf ( SKIP_TEST , '<STR_LIT>' ) <EOL> def test_on_trait_on_trait_change_decorator ( self ) : <EOL> code = """<STR_LIT>""" <EOL> obj = cython . inline ( code , get_type = _always_object_type , force = True , <EOL> locals = { } , globals = { } ) <EOL> with self . assertTraitChanges ( obj , '<STR_LIT:value>' , count = <NUM_LIT:1> ) : <EOL> obj . name = '<STR_LIT>' <EOL> self . assertEqual ( obj . value , <NUM_LIT:1> ) <EOL> @ unittest . skipIf ( SKIP_TEST , '<STR_LIT>' ) <EOL> def test_on_trait_properties ( self ) : <EOL> code = """<STR_LIT>""" <EOL> obj = cython . inline ( code , get_type = _always_object_type , force = True , <EOL> locals = { } , globals = { } ) <EOL> self . assertEqual ( obj . name_len , len ( obj . name ) ) <EOL> obj . name = '<STR_LIT>' <EOL> self . assertEqual ( obj . name_len , len ( obj . name ) ) <EOL> @ unittest . skipIf ( SKIP_TEST , '<STR_LIT>' ) <EOL> def test_on_trait_properties_with_standard_getter ( self ) : <EOL> code = """<STR_LIT>""" <EOL> obj = cython . inline ( code , get_type = _always_object_type , force = True , <EOL> locals = { } , globals = { } ) <EOL> self . assertEqual ( obj . name_len , len ( obj . name ) ) <EOL> obj . name = '<STR_LIT>' <EOL> self . assertEqual ( obj . name_len , len ( obj . name ) ) <EOL> @ unittest . skipIf ( SKIP_TEST , '<STR_LIT>' ) <EOL> def test_on_trait_aliasing ( self ) : <EOL> code = """<STR_LIT>""" <EOL> obj = cython . inline ( code , get_type = _always_object_type , force = True , <EOL> locals = { } , globals = { } ) <EOL> self . assertEqual ( obj . funky_name , obj . name ) <EOL> obj . name = '<STR_LIT>' <EOL> self . assertEqual ( obj . funky_name , obj . name ) <EOL> @ unittest . skipIf ( SKIP_TEST , '<STR_LIT>' ) <EOL> def test_on_trait_aliasing_different_scope ( self ) : <EOL> code = """<STR_LIT>""" <EOL> obj = cython . inline ( code , get_type = _always_object_type ) <EOL> self . assertEqual ( obj . funky_name , obj . name ) <EOL> obj . name = '<STR_LIT>' <EOL> self . assertEqual ( obj . funky_name , obj . name ) <EOL> @ unittest . skipIf ( SKIP_TEST , '<STR_LIT>' ) <EOL> def test_on_trait_lambda_failure ( self ) : <EOL> code = """<STR_LIT>""" <EOL> try : <EOL> cython . inline ( code , get_type = _always_object_type , force = True , <EOL> locals = { } , globals = { } ) <EOL> except : <EOL> pass <EOL> else : <EOL> self . fail ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) </s>
