summaryrefslogtreecommitdiff
path: root/tests/test_process.py
diff options
context:
space:
mode:
authorAndrew Hoos <andrewjhoos@gmail.com>2016-11-30 15:07:51 -0800
committerAndrew Hoos <andrewjhoos@gmail.com>2016-11-30 15:07:51 -0800
commitf807c4271e59a8016f15c8ba4763b0c2d92645a9 (patch)
tree47887b5f04bf49c2d051007f20d162088809d7d9 /tests/test_process.py
parente3bbbfdc30432af2a58e6e8b3f503d213d77c60b (diff)
downloadpython-coveragepy-git-f807c4271e59a8016f15c8ba4763b0c2d92645a9.tar.gz
Update change with tests and fixes for tests
Diffstat (limited to 'tests/test_process.py')
-rw-r--r--tests/test_process.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/test_process.py b/tests/test_process.py
index 75d420a0..dda43ba8 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -785,6 +785,66 @@ class ProcessTest(CoverageTest):
out = self.run_command("python -m coverage")
self.assertIn("Use 'coverage help' for help", out)
+ def test_excepthook(self):
+ self.make_file("test_excepthook.py", """\
+ import sys
+
+ def excepthook(*args):
+ print('in excepthook')
+
+ sys.excepthook = excepthook
+
+ raise RuntimeError('Error Outside')
+ """)
+ cov_st, cov_out = self.run_command_status("coverage run test_excepthook.py")
+ py_st, py_out = self.run_command_status("python test_excepthook.py")
+ self.assertEqual(cov_st, py_st)
+ self.assertEqual(cov_st, 1)
+
+ self.assertIn("in excepthook", py_out)
+ self.assertEqual(cov_out, py_out)
+
+ def test_excepthook_exit(self):
+ self.make_file("test_excepthook_exit.py", """\
+ import sys
+
+ def excepthook(*args):
+ print('in excepthook')
+ sys.exit(0)
+
+ sys.excepthook = excepthook
+
+ raise RuntimeError('Error Outside')
+ """)
+ cov_st, cov_out = self.run_command_status("coverage run test_excepthook_exit.py")
+ py_st, py_out = self.run_command_status("python test_excepthook_exit.py")
+ self.assertEqual(cov_st, py_st)
+ self.assertEqual(cov_st, 0)
+
+ self.assertIn("in excepthook", py_out)
+ self.assertEqual(cov_out, py_out)
+
+ def test_excepthook_throw(self):
+ self.make_file("test_excepthook_exit.py", """\
+ import sys
+
+ def excepthook(*args):
+ print('in excepthook')
+ raise RuntimeError('Error Inside')
+
+ sys.excepthook = excepthook
+
+ raise RuntimeError('Error Outside')
+ """)
+ cov_st, cov_out = self.run_command_status("coverage run test_excepthook_exit.py")
+ py_st, py_out = self.run_command_status("python test_excepthook_exit.py")
+ self.assertEqual(cov_st, py_st)
+ self.assertEqual(cov_st, 0)
+
+ self.assertIn("in excepthook", py_out)
+ self.assertEqual(cov_out, py_out)
+
+
class AliasedCommandTest(CoverageTest):
"""Tests of the version-specific command aliases."""