Author: marky1991 <[email protected]>
Branch: py3.3
Changeset: r81718:dc63814c5a2d
Date: 2016-01-10 19:35 -0500
http://bitbucket.org/pypy/pypy/changeset/dc63814c5a2d/
Log: Add test to see if sys.exceptionhook is used when outputting errors
in code.runsource
diff --git a/pypy/module/test_lib_pypy/test_code_module.py
b/pypy/module/test_lib_pypy/test_code_module.py
--- a/pypy/module/test_lib_pypy/test_code_module.py
+++ b/pypy/module/test_lib_pypy/test_code_module.py
@@ -49,3 +49,17 @@
"""
assert expected_header in result
assert result.endswith("NameError: name '_diana_' is not defined\n")
+
+ def test_excepthook(self):
+ interp = self.get_interp()
+ interp.runsource("import sys")
+ print(interp.runsource("""
+def ignore_failure(type, value, traceback):
+ pass
+"""))
+ print(interp.runsource("sys.excepthook = ignore_failure"))
+ print(interp.runsource("raise TypeError('Invalid Type')"))
+ result = interp.out.getvalue()
+ # Since we have a custom excepthook, the write() method should not
+ # be called
+ assert result == ""
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit