'Simple test for the pid attribute of Process on win32.
Launch process with mock win32process. The only mock aspect of this
module is that the pid of the process created will always be 42.'

def test_pid(self):

    from twisted.internet import _dumbwin32proc
    from twisted.test import mock_win32process
    self.patch(_dumbwin32proc, 'win32process', mock_win32process)
    scriptPath = FilePath(__file__).sibling(u'process_cmdline.py').path
    pyExe = FilePath(sys.executable).asTextMode().path
    d = defer.Deferred()
    processProto = TrivialProcessProtocol(d)
    comspec = u'cmd.exe'
    cmd = [comspec, u'/c', pyExe, scriptPath]
    p = _dumbwin32proc.Process(reactor, processProto, None, cmd, {}, None)
    self.assertEqual(42, p.pid)
    self.assertEqual('<Process    pid=42>', repr(p))
    def pidCompleteCb(result):
        self.assertIsNone(p.pid)
    return d.addCallback(pidCompleteCb)
