Skip to content

Commit 4c0b9f3

Browse files
authored
Merge pull request #4458 from pypa/debt/remove-test-command
Remove test command
2 parents be8e3a0 + 63c89f9 commit 4c0b9f3

16 files changed

+54
-474
lines changed

newsfragments/931.removal.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The test command has been removed. Users relying on 'setup.py test' will need to migrate to another test runner or pin setuptools before this version.

pyproject.toml

-5
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ rotate = "setuptools.command.rotate:rotate"
141141
saveopts = "setuptools.command.saveopts:saveopts"
142142
sdist = "setuptools.command.sdist:sdist"
143143
setopt = "setuptools.command.setopt:setopt"
144-
test = "setuptools.command.test:test"
145144
upload_docs = "setuptools.command.upload_docs:upload_docs"
146145

147146
[project.entry-points."setuptools.finalize_distribution_options"]
@@ -153,19 +152,15 @@ eager_resources = "setuptools.dist:assert_string_list"
153152
namespace_packages = "setuptools.dist:check_nsp"
154153
extras_require = "setuptools.dist:check_extras"
155154
install_requires = "setuptools.dist:check_requirements"
156-
tests_require = "setuptools.dist:check_requirements"
157155
setup_requires = "setuptools.dist:check_requirements"
158156
python_requires = "setuptools.dist:check_specifier"
159157
entry_points = "setuptools.dist:check_entry_points"
160-
test_suite = "setuptools.dist:check_test_suite"
161158
zip_safe = "setuptools.dist:assert_bool"
162159
package_data = "setuptools.dist:check_package_data"
163160
exclude_package_data = "setuptools.dist:check_package_data"
164161
include_package_data = "setuptools.dist:assert_bool"
165162
packages = "setuptools.dist:check_packages"
166163
dependency_links = "setuptools.dist:assert_string_list"
167-
test_loader = "setuptools.dist:check_importable"
168-
test_runner = "setuptools.dist:check_importable"
169164
use_2to3 = "setuptools.dist:invalid_unless_false"
170165

171166
[project.entry-points."egg_info.writers"]

setuptools/_path.py

+42
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import contextlib
12
import os
23
import sys
34
from typing import Union
45

6+
from more_itertools import unique_everseen
7+
8+
59
if sys.version_info >= (3, 9):
610
StrPath = Union[str, os.PathLike[str]] # Same as _typeshed.StrPath
711
else:
@@ -38,3 +42,41 @@ def normpath(filename: StrPath) -> str:
3842
# See pkg_resources.normalize_path for notes about cygwin
3943
file = os.path.abspath(filename) if sys.platform == 'cygwin' else filename
4044
return os.path.normcase(os.path.realpath(os.path.normpath(file)))
45+
46+
47+
@contextlib.contextmanager
48+
def paths_on_pythonpath(paths):
49+
"""
50+
Add the indicated paths to the head of the PYTHONPATH environment
51+
variable so that subprocesses will also see the packages at
52+
these paths.
53+
54+
Do this in a context that restores the value on exit.
55+
56+
>>> getfixture('monkeypatch').setenv('PYTHONPATH', 'anything')
57+
>>> with paths_on_pythonpath(['foo', 'bar']):
58+
... assert 'foo' in os.environ['PYTHONPATH']
59+
... assert 'anything' in os.environ['PYTHONPATH']
60+
>>> os.environ['PYTHONPATH']
61+
'anything'
62+
63+
>>> getfixture('monkeypatch').delenv('PYTHONPATH')
64+
>>> with paths_on_pythonpath(['foo', 'bar']):
65+
... assert 'foo' in os.environ['PYTHONPATH']
66+
>>> os.environ.get('PYTHONPATH')
67+
"""
68+
nothing = object()
69+
orig_pythonpath = os.environ.get('PYTHONPATH', nothing)
70+
current_pythonpath = os.environ.get('PYTHONPATH', '')
71+
try:
72+
prefix = os.pathsep.join(unique_everseen(paths))
73+
to_join = filter(None, [prefix, current_pythonpath])
74+
new_path = os.pathsep.join(to_join)
75+
if new_path:
76+
os.environ['PYTHONPATH'] = new_path
77+
yield
78+
finally:
79+
if orig_pythonpath is nothing:
80+
os.environ.pop('PYTHONPATH', None)
81+
else:
82+
os.environ['PYTHONPATH'] = orig_pythonpath

setuptools/command/test.py

-250
This file was deleted.

setuptools/config/setupcfg.py

-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,6 @@ def parsers(self):
649649
self._parse_requirements_list, "install_requires"
650650
),
651651
'setup_requires': self._parse_list_semicolon,
652-
'tests_require': self._parse_list_semicolon,
653652
'packages': self._parse_packages,
654653
'entry_points': self._parse_file_in_root,
655654
'py_modules': parse_list,

setuptools/dist.py

-11
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,6 @@ def check_entry_points(dist, attr, value):
168168
raise DistutilsSetupError(e) from e
169169

170170

171-
def check_test_suite(dist, attr, value):
172-
if not isinstance(value, str):
173-
raise DistutilsSetupError("test_suite must be a string")
174-
175-
176171
def check_package_data(dist, attr, value):
177172
"""Verify that value is a dictionary of package names to glob lists"""
178173
if not isinstance(value, dict):
@@ -233,12 +228,6 @@ class Distribution(_Distribution):
233228
EasyInstall and requests one of your extras, the corresponding
234229
additional requirements will be installed if needed.
235230
236-
'test_suite' -- the name of a test suite to run for the 'test' command.
237-
If the user runs 'python setup.py test', the package will be installed,
238-
and the named test suite will be run. The format is the same as
239-
would be used on a 'unittest.py' command line. That is, it is the
240-
dotted name of an object to import and call to generate a test suite.
241-
242231
'package_data' -- a dictionary mapping package names to lists of filenames
243232
or globs to use to find data files contained in the named packages.
244233
If the dictionary has filenames or globs listed under '""' (the empty

setuptools/tests/config/setupcfg_examples.txt

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ https://github.com/pallets/click/raw/6411f425fae545f42795665af4162006b36c5e4a/se
1515
https://github.com/sqlalchemy/sqlalchemy/raw/533f5718904b620be8d63f2474229945d6f8ba5d/setup.cfg
1616
https://github.com/pytest-dev/pluggy/raw/461ef63291d13589c4e21aa182cd1529257e9a0a/setup.cfg
1717
https://github.com/pytest-dev/pytest/raw/c7be96dae487edbd2f55b561b31b68afac1dabe6/setup.cfg
18-
https://github.com/tqdm/tqdm/raw/fc69d5dcf578f7c7986fa76841a6b793f813df35/setup.cfg
1918
https://github.com/platformdirs/platformdirs/raw/7b7852128dd6f07511b618d6edea35046bd0c6ff/setup.cfg
2019
https://github.com/pandas-dev/pandas/raw/bc17343f934a33dc231c8c74be95d8365537c376/setup.cfg
2120
https://github.com/django/django/raw/4e249d11a6e56ca8feb4b055b681cec457ef3a3d/setup.cfg

0 commit comments

Comments
 (0)