[TIP] spawning a subprocess from within a pytest test
andre.l.caron at gmail.com
Tue Oct 2 09:05:07 PDT 2018
I do this regularly and it works quite well. However, I have been caught
by environment variables not being forwarded by Tox by default. Check
`passenv` and `setenv` environment settings.
Also, this may be unrelated to your problem, but since you mentioned
running on Windows, I'd advise paying close attention to child process
cleanup. By default, Windows does not automatically terminte child
processes when the parent process dies. If you start any long-running
background processes (e.g. some kind of server process managed by a session
fixture), it can end up dangling after (repeated) CTRL-C or a forceful kill
of the Python process.
On Mon, Oct 1, 2018 at 8:59 PM Bruno Oliveira <nicoddemus at gmail.com> wrote:
> Hi Tony,
> There's nothing in pytest that prevents you to spawn subprocesses. Posting
> your code and the error or problem you are having will probably help
> (specially if the code is small and reproduces the issue).
> On Mon, Oct 1, 2018 at 8:51 PM Tony Cappellini <cappy2112 at gmail.com>
>> I've spent a lot of time trying to figure this out, so I thought I'd ask
>> those who have more experience with Pytest.
>> I'm running Python 2.7.14 on Windows 7 Pro (64-bit), pytest 3.5.0
>> Is there any reason a test running under pytest shouldn't spawn a
>> subprocess, or
>> take special care when spawning it?
>> I'm not able to get a subprocess to launch using subprocess.Popen()
>> inside of a pytest test, but I can run spawn the subrpocess outside of
>> I don't know if I can attach my code to this post.
>> I'll provide more details and the code, after the reply.
>> testing-in-python mailing list
>> testing-in-python at lists.idyll.org
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python