There's the `--boxed` option (from https://pypi.python.org/pypi/pytest-xdist) but you can easily do your own "insulator" by using fork syscall.
Thanks, -- Ionel Cristian Mărieș, http://blog.ionelmc.ro On Thu, Feb 11, 2016 at 10:33 AM, Alessandro Amici <[email protected]> wrote: > Hi, > > I asked the following question on StackOverflow first > http://stackoverflow.com/questions/35322452, 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 :( > > Here is the question: > > I'm interested in executing potentially untrusted tests with pytest in > some kind of sandbox, similarly to what continuous integration services do. > > 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. > > What is the best way to sandbox tests execution in pytest? > > **Update**: This question is not about [python sandboxing in general]( > http://stackoverflow.com/questions/3068139/how-can-i-sandbox-python-in-pure-python) > 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](http://pypy.org/features.html). > > End of question. > > 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): > > https://github.com/alexamici/pytest-wish > > 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 :) > > Alessandro > > > _______________________________________________ > pytest-dev mailing list > [email protected] > https://mail.python.org/mailman/listinfo/pytest-dev > >
_______________________________________________ pytest-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pytest-dev
