diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-11 07:55:05 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-11 07:55:05 -0400 |
commit | fdaa8224ccfa16233fda0c84860ef95ca073ee95 (patch) | |
tree | 58ea8499c9a059358348f620ea98a42aefa69c6b /tests/test_process.py | |
parent | cedd319b6bc76843e570e7e53c4cb98ce359136e (diff) | |
download | python-coveragepy-git-fdaa8224ccfa16233fda0c84860ef95ca073ee95.tar.gz |
test: add more tests of run_python_file
The tests in test_process run the exception handling in execfile.py, but
only under coverage, so metacov can't see it. These smaller tests
exercise the code without coverage on top.
Diffstat (limited to 'tests/test_process.py')
-rw-r--r-- | tests/test_process.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/test_process.py b/tests/test_process.py index 781a0170..63dd1d5b 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -468,8 +468,11 @@ class ProcessTest(CoverageTest): def test_code_throws(self): self.make_file("throw.py", """\ + class MyException(Exception): + pass + def f1(): - raise Exception("hey!") + raise MyException("hey!") def f2(): f1() @@ -488,9 +491,9 @@ class ProcessTest(CoverageTest): # But also make sure that the output is what we expect. path = python_reported_file('throw.py') - msg = f'File "{re.escape(path)}", line 5,? in f2' + msg = f'File "{re.escape(path)}", line 8, in f2' assert re.search(msg, out) - assert 'raise Exception("hey!")' in out + assert 'raise MyException("hey!")' in out assert status == 1 def test_code_exits(self): @@ -1121,7 +1124,7 @@ class ExcepthookTest(CoverageTest): assert cov_st == py_st assert cov_st == 0 - assert "in excepthook" in py_out + assert py_out == "in excepthook\n" assert cov_out == py_out @pytest.mark.skipif(env.PYPY, reason="PyPy handles excepthook throws differently.") |