def testSignBuffer(self):
    intemp = tempfile.NamedTemporaryFile()

    # Simulate osslsign writing the signed file
    outname = "%s.signed" % intemp.name
    open(outname, "w").write("content")

    with mock.patch.object(pexpect, "spawn"):
      with mock.patch.object(signing.subprocess, "check_call"):
        with mock.patch.object(tempfile, "NamedTemporaryFile",
                               return_value=intemp):
          output = self.winsign.SignBuffer("asdflkjlaksjdf")

    self.assertEqual(output, "content")

    with mock.patch.object(pexpect, "spawn",
                           side_effect=pexpect.ExceptionPexpect("blah")):
      with self.assertRaises(pexpect.ExceptionPexpect):
        output = self.winsign.SignBuffer("asdflkjlaksjdf")
dataset/ETHPy150Open google/grr/grr/lib/builders/signing_test.py/WindowsCodeSignerTest.testSignBuffer/original