'Error on second fork should cause report to stderr.'

def test_second_fork_error_reports_to_stderr(self):

    fork_errno = 17
    fork_strerror = 'Nasty    stuff    happened'
    fork_error = OSError(fork_errno, fork_strerror)
    test_pids_iter = iter([0, fork_error])
    def mock_fork():
        next = test_pids_iter.next()
        if isinstance(next, Exception):
            raise next
        else:
            return next
    scaffold.mock('os.fork', returns_func=mock_fork, tracker=self.mock_tracker)
    expect_mock_output = '                                                Called    os.fork()\n                                                Called    os.setsid()\n                                                Called    os.fork()\n                                                '
    self.failUnlessRaises(daemon.daemon.DaemonProcessDetachError, daemon.daemon.detach_process_context)
    self.failUnlessMockCheckerMatch(expect_mock_output)
