<s> import unittest <EOL> from robot . utils . asserts import assert_equal , assert_raises <EOL> from robot . utils import setter , SetterAwareType , PY2 <EOL> if PY2 : <EOL> class BaseWithMeta ( object ) : <EOL> __slots__ = [ ] <EOL> __metaclass__ = SetterAwareType <EOL> else : <EOL> exec ( '''<STR_LIT>''' ) <EOL> class ExampleWithSlots ( BaseWithMeta ) : <EOL> __slots__ = [ ] <EOL> @ setter <EOL> def attr ( self , value ) : <EOL> return value * <NUM_LIT:2> <EOL> @ setter <EOL> def with_doc ( self , value ) : <EOL> """<STR_LIT>""" <EOL> return value <EOL> class Example ( ExampleWithSlots ) : <EOL> pass <EOL> class TestSetter ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . item = Example ( ) <EOL> def test_setting ( self ) : <EOL> self . item . attr = <NUM_LIT:1> <EOL> assert_equal ( self . item . attr , <NUM_LIT:2> ) <EOL> def test_notset ( self ) : <EOL> assert_raises ( AttributeError , getattr , self . item , '<STR_LIT>' ) <EOL> def test_set_other_attr ( self ) : <EOL> self . item . other_attr = <NUM_LIT:1> <EOL> assert_equal ( self . item . other_attr , <NUM_LIT:1> ) <EOL> def test_copy_doc ( self ) : <EOL> assert_equal ( type ( self . item ) . attr . __doc__ , None ) <EOL> assert_equal ( type ( self . item ) . with_doc . __doc__ , "<STR_LIT>" ) <EOL> class TestSetterWithSlotsAndSetterAwareType ( TestSetter ) : <EOL> def setUp ( self ) : <EOL> self . item = ExampleWithSlots ( ) <EOL> def test_set_other_attr ( self ) : <EOL> assert_raises ( AttributeError , setattr , self . item , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
