aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-01-14 21:32:39 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-01-14 21:32:39 -0500
commitc10a38e97daf7aad2167b3b444be8542dccc652e (patch)
tree0dd34f6a5d5aa1d284e2f071d3106d458767eb22
parent19c95d3ef6dba78bf6431b6b13d000bc19e84cd6 (diff)
downloadexternal_python_setuptools-c10a38e97daf7aad2167b3b444be8542dccc652e.tar.gz
external_python_setuptools-c10a38e97daf7aad2167b3b444be8542dccc652e.tar.bz2
external_python_setuptools-c10a38e97daf7aad2167b3b444be8542dccc652e.zip
Add tests for new ExceptionSaver
-rw-r--r--setuptools/tests/test_sandbox.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/setuptools/tests/test_sandbox.py b/setuptools/tests/test_sandbox.py
index 9a2a6b7b..33fb3329 100644
--- a/setuptools/tests/test_sandbox.py
+++ b/setuptools/tests/test_sandbox.py
@@ -54,3 +54,31 @@ class TestSandbox:
with setup_py.open('wb') as stream:
stream.write(b'"degenerate script"\r\n')
setuptools.sandbox._execfile(str(setup_py), globals())
+
+
+class TestExceptionSaver:
+ def test_exception_trapped(self):
+ with setuptools.sandbox.ExceptionSaver():
+ raise ValueError("details")
+
+ def test_exception_resumed(self):
+ with setuptools.sandbox.ExceptionSaver() as saved_exc:
+ raise ValueError("details")
+
+ with pytest.raises(ValueError) as caught:
+ saved_exc.resume()
+
+ assert isinstance(caught.value, ValueError)
+ assert str(caught.value) == 'details'
+
+ def test_exception_reconstructed(self):
+ orig_exc = ValueError("details")
+
+ with setuptools.sandbox.ExceptionSaver() as saved_exc:
+ raise orig_exc
+
+ with pytest.raises(ValueError) as caught:
+ saved_exc.resume()
+
+ assert isinstance(caught.value, ValueError)
+ assert caught.value is not orig_exc