aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-08-08 15:53:41 -0400
committerJason R. Coombs <jaraco@jaraco.com>2020-08-08 16:19:11 -0400
commit41deeb76fc88382f27b3d37cce75eda2c54cbc2a (patch)
tree0942886c46fc8c2a9453d2d2d4ce7824ebd4efba /setuptools/tests
parent6281bd0917882b930d5923d76cc72ff4ee5a7695 (diff)
downloadexternal_python_setuptools-41deeb76fc88382f27b3d37cce75eda2c54cbc2a.tar.gz
external_python_setuptools-41deeb76fc88382f27b3d37cce75eda2c54cbc2a.tar.bz2
external_python_setuptools-41deeb76fc88382f27b3d37cce75eda2c54cbc2a.zip
Bypass pytest-virtualenv due to bugs in 'run' command. Instead, use jaraco.envs.VirtualEnv and build a bespoke fixture with a run command.
Diffstat (limited to 'setuptools/tests')
-rw-r--r--setuptools/tests/requirements.txt1
-rw-r--r--setuptools/tests/test_distutils_adoption.py48
2 files changed, 31 insertions, 18 deletions
diff --git a/setuptools/tests/requirements.txt b/setuptools/tests/requirements.txt
index 19bf5aef..d0d07f70 100644
--- a/setuptools/tests/requirements.txt
+++ b/setuptools/tests/requirements.txt
@@ -10,3 +10,4 @@ pytest-cov>=2.5.1
paver; python_version>="3.6"
futures; python_version=="2.7"
pip>=19.1 # For proper file:// URLs support.
+jaraco.envs
diff --git a/setuptools/tests/test_distutils_adoption.py b/setuptools/tests/test_distutils_adoption.py
index a945a69f..476b0a9e 100644
--- a/setuptools/tests/test_distutils_adoption.py
+++ b/setuptools/tests/test_distutils_adoption.py
@@ -1,8 +1,27 @@
import os
import sys
import functools
+import subprocess
import pytest
+import jaraco.envs
+import path
+
+
+class VirtualEnv(jaraco.envs.VirtualEnv):
+ name = '.env'
+
+ def run(self, cmd, *args, **kwargs):
+ cmd = [self.exe(cmd[0])] + cmd[1:]
+ return subprocess.check_output(cmd, *args, cwd=self.root, **kwargs)
+
+
+@pytest.fixture
+def venv(tmpdir):
+ env = VirtualEnv()
+ env.root = path.Path(tmpdir)
+ env.req = os.getcwd()
+ return env.create()
def popen_text(call):
@@ -13,36 +32,29 @@ def popen_text(call):
if sys.version_info < (3, 7) else functools.partial(call, text=True)
-@pytest.fixture
-def env(virtualenv):
- virtualenv.run(['pip', 'uninstall', '-y', 'setuptools'])
- virtualenv.run(['pip', 'install', os.getcwd()])
- return virtualenv
-
-
-def find_distutils(env, imports='distutils'):
+def find_distutils(venv, imports='distutils', **kwargs):
py_cmd = 'import {imports}; print(distutils.__file__)'.format(**locals())
cmd = ['python', '-c', py_cmd]
- return popen_text(env.run)(cmd, capture=True)
+ return popen_text(venv.run)(cmd, **kwargs)
-def test_distutils_stdlib(env):
+def test_distutils_stdlib(venv):
"""
Ensure stdlib distutils is used when appropriate.
"""
- assert '.env' not in find_distutils(env).split(os.sep)
+ assert venv.name not in find_distutils(venv, env=dict()).split(os.sep)
-def test_distutils_local_with_setuptools(env):
+def test_distutils_local_with_setuptools(venv):
"""
Ensure local distutils is used when appropriate.
"""
- env.env.update(SETUPTOOLS_USE_DISTUTILS='local')
- loc = find_distutils(env, imports='setuptools, distutils')
- assert '.env' in loc.split(os.sep)
+ env = dict(SETUPTOOLS_USE_DISTUTILS='local')
+ loc = find_distutils(venv, imports='setuptools, distutils', env=env)
+ assert venv.name in loc.split(os.sep)
@pytest.mark.xfail(reason="#2259")
-def test_distutils_local(env):
- env.env.update(SETUPTOOLS_USE_DISTUTILS='local')
- assert '.env' in find_distutils(env).split(os.sep)
+def test_distutils_local(venv):
+ env = dict(SETUPTOOLS_USE_DISTUTILS='local')
+ assert venv.name in find_distutils(venv, env=env).split(os.sep)