<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">There's the `--boxed` option (from <a href="https://pypi.python.org/pypi/pytest-xdist">https://pypi.python.org/pypi/pytest-xdist</a>) but you can easily do your own "insulator" by using fork syscall. <br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div><span style="font-family:trebuchet ms,sans-serif"><span style="color:rgb(51,51,51)"><br><font size="2"><span style="color:rgb(51,51,51)">Thanks,</span><br><span style="color:rgb(153,153,153)">-- Ionel</span></font></span><font size="2"><font style="color:rgb(153,153,153)"> Cristian Mărieș, <a href="http://blog.ionelmc.ro" target="_blank">http://blog.ionelmc.ro</a><br></font></font></span></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Feb 11, 2016 at 10:33 AM, Alessandro Amici <span dir="ltr"><<a href="mailto:alexamici@gmail.com" target="_blank">alexamici@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I asked the following question on StackOverflow first <a href="http://stackoverflow.com/questions/35322452" target="_blank">http://stackoverflow.com/questions/35322452</a>, but someone quickly (and wrongly in my opinion) marked that as duplicate of the general "sandboxing in python", so I can't get answers there anymore :(</div><div><br></div><div>Here is the question:</div><div><br></div><div><div>I'm interested in executing potentially untrusted tests with pytest in some kind of sandbox, similarly to what continuous integration services do.</div><div><br></div><div>I understand that to properly sandbox a python process you need OS-level isolation, like running the tests in a disposable chroot/container, but in my use case I don't need to protect against intentionally malicious code, only from dangerous behaviour of pairing "randomly" functions with arguments. So lesser strict sandboxing may still be acceptable. But I didn't find any plugin that enables any form of sandboxing.</div><div><br></div><div>What is the best way to sandbox tests execution in pytest?</div><div><br></div><div>**Update**: This question is not about [python sandboxing in general](<a href="http://stackoverflow.com/questions/3068139/how-can-i-sandbox-python-in-pure-python" target="_blank">http://stackoverflow.com/questions/3068139/how-can-i-sandbox-python-in-pure-python</a>) as the tests' code is run by pytest and I can't change the way it is executed to use `exec` or `ast` or whatever. Also using pypy-sandbox is not an option unfortunately as it is "a prototype only" as per the [PyPy feature page](<a href="http://pypy.org/features.html" target="_blank">http://pypy.org/features.html</a>).</div></div><div><br></div><div>End of question.</div><div><br></div><div>For context I'm writing a pytest plugin that lets you search installed modules for functions that pass the given feature-specification tests (still alpha):</div><div><br></div><div><a href="https://github.com/alexamici/pytest-wish" target="_blank">https://github.com/alexamici/pytest-wish</a></div><div><br></div><div>If you find the question useful and not answered already on stackoverflow, the best course of action would be to reopen it and answer there, but I'll take also an answer here :)</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Alessandro</div><div><br></div></font></span></div>
<br>_______________________________________________<br>
pytest-dev mailing list<br>
<a href="mailto:pytest-dev@python.org">pytest-dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/pytest-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/pytest-dev</a><br>
<br></blockquote></div><br></div>