<s> import unittest <EOL> import IECore <EOL> import Gaffer <EOL> import GafferTest <EOL> class OrphanRemoverTest ( GafferTest . TestCase ) : <EOL> def test ( self ) : <EOL> p = Gaffer . GraphComponent ( ) <EOL> c1 = Gaffer . GraphComponent ( ) <EOL> c2 = Gaffer . GraphComponent ( ) <EOL> p [ "<STR_LIT>" ] = c1 <EOL> p [ "<STR_LIT>" ] = c2 <EOL> s = Gaffer . StandardSet ( p . children ( ) ) <EOL> b = Gaffer . Behaviours . OrphanRemover ( s ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertTrue ( c1 in s ) <EOL> self . assertTrue ( c2 in s ) <EOL> p . removeChild ( c1 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertFalse ( c1 in s ) <EOL> self . assertTrue ( c2 in s ) <EOL> p [ "<STR_LIT>" ] = c1 <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertFalse ( c1 in s ) <EOL> self . assertTrue ( c2 in s ) <EOL> s . add ( c1 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertTrue ( c1 in s ) <EOL> self . assertTrue ( c2 in s ) <EOL> p . removeChild ( c1 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertFalse ( c1 in s ) <EOL> self . assertTrue ( c2 in s ) <EOL> p . removeChild ( c2 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:0> ) <EOL> self . assertFalse ( c1 in s ) <EOL> self . assertFalse ( c2 in s ) <EOL> c3 = Gaffer . GraphComponent ( ) <EOL> s . add ( c3 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertFalse ( c1 in s ) <EOL> self . assertFalse ( c2 in s ) <EOL> self . assertTrue ( c3 in s ) <EOL> p [ "<STR_LIT>" ] = c3 <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertFalse ( c1 in s ) <EOL> self . assertFalse ( c2 in s ) <EOL> self . assertTrue ( c3 in s ) <EOL> p . removeChild ( c3 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:0> ) <EOL> self . assertFalse ( c1 in s ) <EOL> self . assertFalse ( c2 in s ) <EOL> self . assertFalse ( c3 in s ) <EOL> p [ "<STR_LIT>" ] = c3 <EOL> s . add ( c3 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertFalse ( c1 in s ) <EOL> self . assertFalse ( c2 in s ) <EOL> self . assertTrue ( c3 in s ) <EOL> del b <EOL> p . removeChild ( c3 ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertFalse ( c1 in s ) <EOL> self . assertFalse ( c2 in s ) <EOL> self . assertTrue ( c3 in s ) <EOL> def testImportFrom ( self ) : <EOL> from Gaffer . Behaviours import OrphanRemover <EOL> self . assertTrue ( OrphanRemover is Gaffer . Behaviours . OrphanRemover ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
