From 7ce51484f1048cfa60400d2e62121d896be37fb5 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 2 Nov 2021 07:50:51 -0400 Subject: [PATCH] test(fix): isolate excepthook tests from each other --- tests/test_execfile.py | 7 +++++++ tests/test_process.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/tests/test_execfile.py b/tests/test_execfile.py index 21cbb7270..b7a099028 100644 --- a/tests/test_execfile.py +++ b/tests/test_execfile.py @@ -10,6 +10,7 @@ import pathlib import py_compile import re +import sys import pytest @@ -26,6 +27,12 @@ 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 7d7875d0f..e048bdc2a 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -1092,6 +1092,8 @@ def test_bug_909(self): 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