diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-03-06 16:19:57 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-03-06 16:19:57 -0500 |
commit | a2719779b6604634f87aed64cf4413486ccca88c (patch) | |
tree | 028e9b4d6718d551ec266b43733dfe967433475e | |
parent | ac3e0877123c9cb1a4d53653e273dfb3f1d40ed3 (diff) | |
download | external_python_setuptools-a2719779b6604634f87aed64cf4413486ccca88c.tar.gz external_python_setuptools-a2719779b6604634f87aed64cf4413486ccca88c.tar.bz2 external_python_setuptools-a2719779b6604634f87aed64cf4413486ccca88c.zip |
Extract install_target as fixture
-rw-r--r-- | setuptools/tests/test_easy_install.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 791e3038..1acf08b5 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -188,20 +188,23 @@ class TestUserInstallTest: f.write('Name: foo\n') return str(tmpdir) - def test_local_index(self, foo_package): + @pytest.fixture() + def install_target(self, tmpdir): + return str(tmpdir) + + def test_local_index(self, foo_package, install_target): """ The local index must be used when easy_install locates installed packages. """ - target = tempfile.mkdtemp() - sys.path.append(target) + sys.path.append(install_target) old_ppath = os.environ.get('PYTHONPATH') os.environ['PYTHONPATH'] = os.path.pathsep.join(sys.path) try: dist = Distribution() dist.script_name = 'setup.py' cmd = ei.easy_install(dist) - cmd.install_dir = target + cmd.install_dir = install_target cmd.args = ['foo'] cmd.ensure_finalized() cmd.local_index.scan([foo_package]) @@ -210,14 +213,7 @@ class TestUserInstallTest: expected = os.path.normcase(os.path.realpath(foo_package)) assert actual == expected finally: - sys.path.remove(target) - for basedir in [target, ]: - if not os.path.exists(basedir) or not os.path.isdir(basedir): - continue - try: - shutil.rmtree(basedir) - except: - pass + sys.path.remove(install_target) if old_ppath is not None: os.environ['PYTHONPATH'] = old_ppath else: |