<s> import unittest <EOL> import Gaffer <EOL> import GafferTest <EOL> class ChildSetTest ( GafferTest . TestCase ) : <EOL> def test ( self ) : <EOL> p = Gaffer . GraphComponent ( ) <EOL> s = Gaffer . ChildSet ( p ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:0> ) <EOL> g1 = Gaffer . GraphComponent ( ) <EOL> p . addChild ( g1 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . failUnless ( s . contains ( g1 ) ) <EOL> self . failUnless ( s [ <NUM_LIT:0> ] . isSame ( g1 ) ) <EOL> p . removeChild ( g1 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:0> ) <EOL> self . failIf ( s . contains ( g1 ) ) <EOL> def testSignals ( self ) : <EOL> mirrorSet = set ( ) <EOL> def added ( s , member ) : <EOL> mirrorSet . add ( member ) <EOL> def removed ( s , member ) : <EOL> mirrorSet . remove ( member ) <EOL> p = Gaffer . GraphComponent ( ) <EOL> s = Gaffer . ChildSet ( p ) <EOL> addedConnection = s . memberAddedSignal ( ) . connect ( added ) <EOL> removedConnection = s . memberRemovedSignal ( ) . connect ( removed ) <EOL> p [ "<STR_LIT>" ] = Gaffer . GraphComponent ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( mirrorSet , set ( s ) ) <EOL> del p [ "<STR_LIT>" ] <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( mirrorSet , set ( s ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
