diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-12-13 11:10:33 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-12-13 11:10:33 -0500 |
commit | 3915be7722713c51aab291ed9720c7b83585d2b5 (patch) | |
tree | 4b220ca9d43d9d5bd48f57e51e6320bb6d538cf6 | |
parent | ce481836f31142b939f4b93a6eba90630ba354fd (diff) | |
download | external_python_setuptools-3915be7722713c51aab291ed9720c7b83585d2b5.tar.gz external_python_setuptools-3915be7722713c51aab291ed9720c7b83585d2b5.tar.bz2 external_python_setuptools-3915be7722713c51aab291ed9720c7b83585d2b5.zip |
Add another test capturing violated expectation that SandboxViolation would be raised in a sandbox/hidden_setuptools context. Ref #440.
-rw-r--r-- | setuptools/tests/test_sandbox.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/setuptools/tests/test_sandbox.py b/setuptools/tests/test_sandbox.py index 40bd2ebe..fefd46f7 100644 --- a/setuptools/tests/test_sandbox.py +++ b/setuptools/tests/test_sandbox.py @@ -118,3 +118,24 @@ class TestExceptionSaver: msg, = caught.value.args assert msg == 'ExceptionUnderTest()' + + def test_sandbox_violation_raised_hiding_setuptools(self, tmpdir): + """ + When in a sandbox with setuptools hidden, a SandboxViolation + should reflect a proper exception and not be wrapped in + an UnpickleableException. + """ + def write_file(): + "Trigger a SandboxViolation by writing outside the sandbox" + with open('/etc/foo', 'w'): + pass + sandbox = DirectorySandbox(str(tmpdir)) + with pytest.raises(setuptools.sandbox.SandboxViolation) as caught: + with setuptools.sandbox.save_modules(): + setuptools.sandbox.hide_setuptools() + sandbox.run(write_file) + + cmd, args, kwargs = caught.value.args + assert cmd == 'open' + assert args == ('/etc/foo', 'w') + assert kwargs == {} |