aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-03-16 06:31:10 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-03-16 06:31:10 -0400
commit70bbc5c7a66df8a8cfb3c0fa4e90644da530a78b (patch)
tree2b01da003651263bb78790bc233f2e06d8fba025 /setup.py
parentd68b390410c2f3ee0d3e47c95fe556cd29cb3c78 (diff)
downloadexternal_python_setuptools-70bbc5c7a66df8a8cfb3c0fa4e90644da530a78b.tar.gz
external_python_setuptools-70bbc5c7a66df8a8cfb3c0fa4e90644da530a78b.tar.bz2
external_python_setuptools-70bbc5c7a66df8a8cfb3c0fa4e90644da530a78b.zip
Use a context manager instead of calling _test.run in multiple places. Alleviates need to warn about Exceptions
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index 19a1dfb7..6bcea951 100755
--- a/setup.py
+++ b/setup.py
@@ -4,6 +4,7 @@ import io
import os
import sys
import textwrap
+import contextlib
# Allow to run setup.py from another directory.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
@@ -63,19 +64,24 @@ class build_py(_build_py):
class test(_test):
"""Specific test class to avoid rewriting the entry_points.txt"""
def run(self):
+ with self._save_entry_points():
+ _test.run(self)
+
+ @contextlib.contextmanager
+ def _save_entry_points(self):
entry_points = os.path.join('setuptools.egg-info', 'entry_points.txt')
if not os.path.exists(entry_points):
- _test.run(self)
- return # even though _test.run will raise SystemExit
+ yield
+ return
# save the content
with open(entry_points, 'rb') as f:
ep_content = f.read()
- # run the test
+ # run the tests
try:
- _test.run(self)
+ yield
finally:
# restore the file
with open(entry_points, 'wb') as f: