<s> """<STR_LIT>""" <EOL> import tempfile <EOL> import mock <EOL> import pexpect <EOL> from grr . lib import flags <EOL> from grr . lib import test_lib <EOL> from grr . lib . builders import signing <EOL> class WindowsCodeSignerTest ( test_lib . GRRBaseTest ) : <EOL> def setUp ( self ) : <EOL> super ( WindowsCodeSignerTest , self ) . setUp ( ) <EOL> self . winsign = signing . WindowsCodeSigner ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def testSignBuffer ( self ) : <EOL> intemp = tempfile . NamedTemporaryFile ( ) <EOL> outname = "<STR_LIT>" % intemp . name <EOL> open ( outname , "<STR_LIT:w>" ) . write ( "<STR_LIT:content>" ) <EOL> with mock . patch . object ( pexpect , "<STR_LIT>" ) : <EOL> with mock . patch . object ( signing . subprocess , "<STR_LIT>" ) : <EOL> with mock . patch . object ( tempfile , "<STR_LIT>" , <EOL> return_value = intemp ) : <EOL> output = self . winsign . SignBuffer ( "<STR_LIT>" ) <EOL> self . assertEqual ( output , "<STR_LIT:content>" ) <EOL> with mock . patch . object ( pexpect , "<STR_LIT>" , <EOL> side_effect = pexpect . ExceptionPexpect ( "<STR_LIT>" ) ) : <EOL> with self . assertRaises ( pexpect . ExceptionPexpect ) : <EOL> output = self . winsign . SignBuffer ( "<STR_LIT>" ) <EOL> def main ( argv ) : <EOL> test_lib . main ( argv ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> flags . StartMain ( main ) </s>
