aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-03-06 16:33:25 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-03-06 16:33:25 -0500
commitc3b4d4bc997f71943b29bb8dccbdfcbc72bd7488 (patch)
tree53e7fcc9fed1b53be67297b98ef677d5de87518a
parenta2719779b6604634f87aed64cf4413486ccca88c (diff)
downloadexternal_python_setuptools-c3b4d4bc997f71943b29bb8dccbdfcbc72bd7488.tar.gz
external_python_setuptools-c3b4d4bc997f71943b29bb8dccbdfcbc72bd7488.tar.bz2
external_python_setuptools-c3b4d4bc997f71943b29bb8dccbdfcbc72bd7488.zip
Extract sys.path and os.environ patching into install_target fixture
-rw-r--r--setuptools/tests/test_easy_install.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index 1acf08b5..6e2b25dd 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -188,18 +188,19 @@ class TestUserInstallTest:
f.write('Name: foo\n')
return str(tmpdir)
- @pytest.fixture()
+ @pytest.yield_fixture()
def install_target(self, tmpdir):
- return str(tmpdir)
+ target = str(tmpdir)
+ with mock.patch('sys.path', sys.path + [target]):
+ python_path = os.path.pathsep.join(sys.path)
+ with mock.patch.dict(os.environ, PYTHONPATH=python_path):
+ yield target
def test_local_index(self, foo_package, install_target):
"""
The local index must be used when easy_install locates installed
packages.
"""
- 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'
@@ -213,11 +214,7 @@ class TestUserInstallTest:
expected = os.path.normcase(os.path.realpath(foo_package))
assert actual == expected
finally:
- sys.path.remove(install_target)
- if old_ppath is not None:
- os.environ['PYTHONPATH'] = old_ppath
- else:
- del os.environ['PYTHONPATH']
+ pass
@contextlib.contextmanager
def user_install_setup_context(self, *args, **kwargs):