summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-02 07:50:51 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-11-02 08:12:51 -0400
commit87987b1237a85001965385875b3eaddb02da43be (patch)
treef38569df1e8af8195dba6c44ade454ac737b67ee
parent8a3bf9edc919e87605a8079aa11a3494f562a9b0 (diff)
downloadpython-coveragepy-git-87987b1237a85001965385875b3eaddb02da43be.tar.gz
test(fix): isolate excepthook tests from each other
-rw-r--r--tests/test_execfile.py7
-rw-r--r--tests/test_process.py2
2 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_execfile.py b/tests/test_execfile.py
index 21cbb727..b7a09902 100644
--- a/tests/test_execfile.py
+++ b/tests/test_execfile.py
@@ -10,6 +10,7 @@ import os.path
import pathlib
import py_compile
import re
+import sys
import pytest
@@ -26,6 +27,12 @@ TRY_EXECFILE = os.path.join(TESTS_DIR, "modules/process_test/try_execfile.py")
class RunFileTest(CoverageTest):
"""Test cases for `run_python_file`."""
+ @pytest.fixture(autouse=True)
+ def clean_up(self):
+ """These tests all run in-process. Clean up global changes."""
+ yield
+ sys.excepthook = sys.__excepthook__
+
def test_run_python_file(self):
run_python_file([TRY_EXECFILE, "arg1", "arg2"])
mod_globs = json.loads(self.stdout())
diff --git a/tests/test_process.py b/tests/test_process.py
index 7d7875d0..e048bdc2 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -1092,6 +1092,8 @@ class EnvironmentTest(CoverageTest):
class ExcepthookTest(CoverageTest):
"""Tests of sys.excepthook support."""
+ # TODO: do we need these as process tests if we have test_execfile.py:RunFileTest?
+
def test_excepthook(self):
self.make_file("excepthook.py", """\
import sys