diff --git a/changelog.d/3336.misc.rst b/changelog.d/3336.misc.rst new file mode 100644 index 0000000000..288b1eb3ac --- /dev/null +++ b/changelog.d/3336.misc.rst @@ -0,0 +1 @@ +Modified ``test_setup_install_includes_dependencies`` to work with custom ``PYTHONPATH`` –- by :user:`hroncok` \ No newline at end of file diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 726f9fda5a..73a8dfff08 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -474,22 +474,27 @@ def test_setup_install_includes_dependencies(self, tmp_path, mock_index): '--install-purelib', str(install_root), '--install-platlib', str(install_root), ] - env = {"PYTHONPATH": str(install_root), "__EASYINSTALL_INDEX": mock_index.url} - with pytest.raises(subprocess.CalledProcessError) as exc_info: - subprocess.check_output( - cmd, cwd=str(project_root), env=env, stderr=subprocess.STDOUT, text=True - ) + env = {**os.environ, "__EASYINSTALL_INDEX": mock_index.url} + cp = subprocess.run( + cmd, + cwd=str(project_root), + env=env, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + assert cp.returncode != 0 try: assert '/does-not-exist/' in {r.path for r in mock_index.requests} assert next( line - for line in exc_info.value.output.splitlines() + for line in cp.stdout.splitlines() if "not find suitable distribution for" in line and "does-not-exist" in line ) except Exception: - if "failed to get random numbers" in exc_info.value.output: - pytest.xfail(f"{sys.platform} failure - {exc_info.value.output}") + if "failed to get random numbers" in cp.stdout: + pytest.xfail(f"{sys.platform} failure - {cp.stdout}") raise def create_project(self, root):