diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-02-05 21:35:39 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-02-05 21:35:39 -0500 |
commit | 929245d2582e5dba93540838981494fd5a57dbdf (patch) | |
tree | d09122934923340fb0a4be1864ffb8914ced9e69 | |
parent | 023cc7621f21b660b1eed7561f1a4c8caabb125c (diff) | |
download | external_python_setuptools-929245d2582e5dba93540838981494fd5a57dbdf.tar.gz external_python_setuptools-929245d2582e5dba93540838981494fd5a57dbdf.tar.bz2 external_python_setuptools-929245d2582e5dba93540838981494fd5a57dbdf.zip |
Rewrite merged tests to use context managers
-rw-r--r-- | setuptools/tests/test_easy_install.py | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index e58379ab..fbba1803 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -315,26 +315,23 @@ class TestSetupRequires(unittest.TestCase): version='0.0') working_set.add(fake_dist) - def setup_and_run(temp_dir): - test_pkg = create_setup_requires_package(temp_dir) - test_setup_py = os.path.join(test_pkg, 'setup.py') - try: - stdout, stderr = quiet_context( - lambda: reset_setup_stop_context( - # Don't even need to install the package, just running - # the setup.py at all is sufficient - lambda: run_setup(test_setup_py, ['--name']) - )) - except VersionConflict: - self.fail('Installing setup.py requirements caused ' - 'VersionConflict') - - lines = stdout.splitlines() - self.assertTrue(len(lines) > 0) - self.assertTrue(lines[-1].strip(), 'test_pkg') - try: - tempdir_context(setup_and_run) + with tempdir_context() as temp_dir: + test_pkg = create_setup_requires_package(temp_dir) + test_setup_py = os.path.join(test_pkg, 'setup.py') + with quiet_context() as (stdout, stderr): + with reset_setup_stop_context(): + try: + # Don't even need to install the package, just + # running the setup.py at all is sufficient + run_setup(test_setup_py, ['--name']) + except VersionConflict: + self.fail('Installing setup.py requirements ' + 'caused a VersionConflict') + + lines = stdout.splitlines() + self.assertTrue(len(lines) > 0) + self.assertTrue(lines[-1].strip(), 'test_pkg') finally: pkg_resources.__setstate__(pr_state) |