<s> import os <EOL> import IECore <EOL> import Gaffer <EOL> import GafferImage <EOL> import GafferTest <EOL> import GafferImageTest <EOL> class CopyImageMetadataTest ( GafferImageTest . ImageTestCase ) : <EOL> checkerFile = os . path . expandvars ( "<STR_LIT>" ) <EOL> def test ( self ) : <EOL> r = GafferImage . ImageReader ( ) <EOL> r [ "<STR_LIT>" ] . setValue ( self . checkerFile ) <EOL> inMetadata = r [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) <EOL> d = GafferImage . DeleteImageMetadata ( ) <EOL> d [ "<STR_LIT>" ] . setInput ( r [ "<STR_LIT>" ] ) <EOL> d [ "<STR_LIT>" ] . setValue ( "<STR_LIT:*>" ) <EOL> m = GafferImage . CopyImageMetadata ( ) <EOL> m [ "<STR_LIT>" ] . setInput ( d [ "<STR_LIT>" ] ) <EOL> m [ "<STR_LIT>" ] . setInput ( r [ "<STR_LIT>" ] ) <EOL> m [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> metadata = m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) <EOL> self . assertEqual ( m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . CompoundObject ( ) ) <EOL> self . assertEqual ( m [ "<STR_LIT>" ] . image ( ) , d [ "<STR_LIT>" ] . image ( ) ) <EOL> m [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> metadata = m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) <EOL> expected = set ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( set ( metadata . keys ( ) ) , expected ) <EOL> for key in metadata . keys ( ) : <EOL> self . assertEqual ( metadata [ key ] , inMetadata [ key ] ) <EOL> m [ "<STR_LIT>" ] . setValue ( True ) <EOL> metadata = m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) <EOL> expected = set ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( set ( metadata . keys ( ) ) , expected ) <EOL> for key in metadata . keys ( ) : <EOL> self . assertEqual ( metadata [ key ] , inMetadata [ key ] ) <EOL> def testOverwrite ( self ) : <EOL> r = GafferImage . ImageReader ( ) <EOL> r [ "<STR_LIT>" ] . setValue ( self . checkerFile ) <EOL> inMetadata = r [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) <EOL> a = GafferImage . ImageMetadata ( ) <EOL> a [ "<STR_LIT>" ] . addMember ( "<STR_LIT>" , IECore . StringData ( "<STR_LIT>" ) ) <EOL> m = GafferImage . CopyImageMetadata ( ) <EOL> m [ "<STR_LIT>" ] . setInput ( r [ "<STR_LIT>" ] ) <EOL> m [ "<STR_LIT>" ] . setInput ( a [ "<STR_LIT>" ] ) <EOL> m [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> metadata = m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) <EOL> self . assertEqual ( metadata [ "<STR_LIT>" ] , IECore . StringData ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , inMetadata ) <EOL> self . assertEqual ( m [ "<STR_LIT>" ] . image ( ) , r [ "<STR_LIT>" ] . image ( ) ) <EOL> m [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> metadata = m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) <EOL> self . assertTrue ( "<STR_LIT>" in metadata . keys ( ) ) <EOL> self . assertEqual ( metadata [ "<STR_LIT>" ] , IECore . StringData ( "<STR_LIT>" ) ) <EOL> def testDirtyPropogation ( self ) : <EOL> c = GafferImage . Constant ( ) <EOL> r = GafferImage . ImageReader ( ) <EOL> r [ "<STR_LIT>" ] . setValue ( self . checkerFile ) <EOL> inMetadata = r [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) <EOL> m = GafferImage . CopyImageMetadata ( ) <EOL> m [ "<STR_LIT>" ] . setInput ( c [ "<STR_LIT>" ] ) <EOL> m [ "<STR_LIT>" ] . setInput ( r [ "<STR_LIT>" ] ) <EOL> cs = GafferTest . CapturingSlot ( m . plugDirtiedSignal ( ) ) <EOL> m [ "<STR_LIT>" ] . setInput ( c [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( m [ "<STR_LIT>" ] [ "<STR_LIT>" ] in set ( e [ <NUM_LIT:0> ] for e in cs ) ) <EOL> del cs [ : ] <EOL> m [ "<STR_LIT>" ] . setValue ( "<STR_LIT:test>" ) <EOL> self . assertTrue ( m [ "<STR_LIT>" ] [ "<STR_LIT>" ] in set ( e [ <NUM_LIT:0> ] for e in cs ) ) <EOL> del cs [ : ] <EOL> m [ "<STR_LIT>" ] . setValue ( True ) <EOL> self . assertTrue ( m [ "<STR_LIT>" ] [ "<STR_LIT>" ] in set ( e [ <NUM_LIT:0> ] for e in cs ) ) <EOL> def testPassThrough ( self ) : <EOL> c = GafferImage . Constant ( ) <EOL> i = GafferImage . ImageReader ( ) <EOL> i [ "<STR_LIT>" ] . setValue ( self . checkerFile ) <EOL> m = GafferImage . CopyImageMetadata ( ) <EOL> m [ "<STR_LIT>" ] . setInput ( i [ "<STR_LIT>" ] ) <EOL> m [ "<STR_LIT>" ] . setValue ( "<STR_LIT:*>" ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) , m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) , m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) , m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) ) <EOL> context = Gaffer . Context ( ) <EOL> context [ "<STR_LIT>" ] = IECore . V2i ( <NUM_LIT:0> ) <EOL> with context : <EOL> for c in [ "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT:A>" ] : <EOL> context [ "<STR_LIT>" ] = c <EOL> self . assertEqual ( i [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) , m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , m [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
