'Verify that the flags passed to win32process.CreateProcess() prevent a
new console window from being created. Use the following script
to test this interactively::
# Add the following lines to a script named
#   should_not_open_console.pyw
from twisted.internet import reactor, utils
def write_result(result):
open("output.log", "w").write(repr(result))
reactor.stop()
PING_EXE = r"c:\windows\system32\ping.exe"
d = utils.getProcessOutput(PING_EXE, ["slashdot.org"])
d.addCallbacks(write_result)
reactor.run()
To test this, run::
pythonw.exe should_not_open_console.pyw'

@defer.inlineCallbacks
def test_flags(self):

    from twisted.internet import _dumbwin32proc
    flags = []
    realCreateProcess = _dumbwin32proc.win32process.CreateProcess
    def fakeCreateprocess(appName, commandLine, processAttributes, threadAttributes, bInheritHandles, creationFlags, newEnvironment, currentDirectory, startupinfo):
        '\n                                                See    the    Windows    API    documentation    for    I{CreateProcess}    for    further    details.\n\n                                                @param    appName:    The    name    of    the    module    to    be    executed\n                                                @param    commandLine:    The    command    line    to    be    executed.\n                                                @param    processAttributes:    Pointer    to    SECURITY_ATTRIBUTES    structure    or    None.\n                                                @param    threadAttributes:    Pointer    to    SECURITY_ATTRIBUTES    structure    or        None\n                                                @param    bInheritHandles:    boolean    to    determine    if    inheritable    handles    from    this\n                                                                                                                                                process    are    inherited    in    the    new    process\n                                                @param    creationFlags:    flags    that    control    priority    flags    and    creation    of    process.\n                                                @param    newEnvironment:    pointer    to    new    environment    block    for    new    process,    or    None.\n                                                @param    currentDirectory:    full    path    to    current    directory    of    new    process.\n                                                @param    startupinfo:    Pointer    to    STARTUPINFO    or    STARTUPINFOEX    structure\n                                                @return:    True    on    success,    False    on    failure\n                                                @rtype:    L{bool}\n                                                '
        flags.append(creationFlags)
        return realCreateProcess(appName, commandLine, processAttributes, threadAttributes, bInheritHandles, creationFlags, newEnvironment, currentDirectory, startupinfo)
    self.patch(_dumbwin32proc.win32process, 'CreateProcess', fakeCreateprocess)
    exe = sys.executable
    scriptPath = FilePath(__file__).sibling('process_cmdline.py')
    d = defer.Deferred()
    processProto = TrivialProcessProtocol(d)
    comspec = str(os.environ['COMSPEC'])
    cmd = [comspec, '/c', exe, scriptPath.path]
    _dumbwin32proc.Process(reactor, processProto, None, cmd, {}, None)
    (yield d)
    self.assertEqual(flags, [_dumbwin32proc.win32process.CREATE_NO_WINDOW])
