[pytest-dev] How to sandbox test execution with pytest
alexamici at gmail.com
Thu Feb 11 03:33:09 EST 2016
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](
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
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
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 :)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pytest-dev