#NEWLINE# def test_protected_from_python_subclass( self ) : #NEWLINE# #INDENT# class PySubVisible ( Visible ) : #NEWLINE# #INDENT# def __init__( self , publicValue = None ) : #NEWLINE# #INDENT# if ( publicValue is not None ) : #NEWLINE# #INDENT# Visible . __init__ ( self , publicValue ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# Visible . __init__ ( self ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# class SubPySubVisible ( PySubVisible ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# for cls in ( PySubVisible , SubPySubVisible ) : #NEWLINE# #INDENT# s = cls ( ) #NEWLINE# self . assertEquals ( Results . PROTECTED_METHOD , s . protectedMethod ( 0 ) ) #NEWLINE# self . assertEquals ( Results . OVERLOADED_PROTECTED_METHOD , s . protectedMethod ( 'foo' ) ) #NEWLINE# self . assertEquals ( Results . UNUSED , PySubVisible ( Results . UNUSED ) . visibleField ) #NEWLINE# self . assertRaises ( TypeError , OnlySubclassable , 'Calling a Java class with protected constructors should raise a TypeError' ) #NEWLINE# #UNINDENT# class SubSubclassable ( OnlySubclassable ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# sub = SubSubclassable ( ) #NEWLINE# self . assert_ ( ( not ( cls . filledInByConstructor == 0 ) ) , "Creating SubSubclassable should call OnlySubclassable's constructor to fill in\n                filledInByConstructor" ) #NEWLINE# class TestObservable ( Observable ) : #NEWLINE# #INDENT# def __init__( self ) : #NEWLINE# #INDENT# self . props = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# def set( self , key , val ) : #NEWLINE# #INDENT# self . props [ key ] = val #NEWLINE# self . setChanged ( ) #NEWLINE# self . notifyObservers ( ) #NEWLINE# #UNINDENT# #UNINDENT# to = TestObservable ( ) #NEWLINE# self . updated = False #NEWLINE# class TestObserver ( Observer ) : #NEWLINE# #INDENT# def update( observerself , observable , arg ) : #NEWLINE# #INDENT# self . assertEquals ( to , observable ) #NEWLINE# self . assertEquals ( None , arg ) #NEWLINE# self . updated = True #NEWLINE# #UNINDENT# #UNINDENT# to . addObserver ( TestObserver ( ) ) #NEWLINE# to . set ( 'k' , 'v' ) #NEWLINE# self . assert_ ( self . updated , 'Calling set should notify the added observer' )