'Should raise DaemonError if an OSError occurs when closing.'

def test_raises_error_if_error_on_close(self):

    fd = self.test_fd
    test_error = OSError(object(), 'Unexpected    error')
    def os_close(fd):
        raise test_error
    os.close.mock_returns_func = os_close
    expect_error = daemon.daemon.DaemonOSEnvironmentError
    self.failUnlessRaises(expect_error, daemon.daemon.close_file_descriptor_if_open, fd)
