summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setuptools/tests/contexts.py8
-rw-r--r--setuptools/tests/test_test.py7
2 files changed, 10 insertions, 5 deletions
diff --git a/setuptools/tests/contexts.py b/setuptools/tests/contexts.py
index a604cd41..d06a333f 100644
--- a/setuptools/tests/contexts.py
+++ b/setuptools/tests/contexts.py
@@ -83,3 +83,11 @@ def save_user_site_setting():
yield saved
finally:
site.ENABLE_USER_SITE = saved
+
+
+@contextlib.contextmanager
+def suppress_exceptions(*excs):
+ try:
+ yield
+ except excs:
+ pass
diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py
index 51c3a9b4..41b7d078 100644
--- a/setuptools/tests/test_test.py
+++ b/setuptools/tests/test_test.py
@@ -91,9 +91,6 @@ class TestTestTest:
cmd.install_dir = site.USER_SITE
cmd.user = 1
with contexts.quiet():
- try:
+ # The test runner calls sys.exit
+ with contexts.suppress_exceptions(SystemExit):
cmd.run()
- except SystemExit:
- # The test runner calls sys.exit; suppress the exception
- pass
-