Skip to content

Commit

Permalink
Merge pull request #4458 from pypa/debt/remove-test-command
Browse files Browse the repository at this point in the history
Remove test command
  • Loading branch information
jaraco committed Jul 28, 2024
2 parents be8e3a0 + 63c89f9 commit 4c0b9f3
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 474 deletions.
1 change: 1 addition & 0 deletions newsfragments/931.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +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.
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ rotate = "setuptools.command.rotate:rotate"
saveopts = "setuptools.command.saveopts:saveopts"
sdist = "setuptools.command.sdist:sdist"
setopt = "setuptools.command.setopt:setopt"
test = "setuptools.command.test:test"
upload_docs = "setuptools.command.upload_docs:upload_docs"

[project.entry-points."setuptools.finalize_distribution_options"]
Expand All @@ -153,19 +152,15 @@ eager_resources = "setuptools.dist:assert_string_list"
namespace_packages = "setuptools.dist:check_nsp"
extras_require = "setuptools.dist:check_extras"
install_requires = "setuptools.dist:check_requirements"
tests_require = "setuptools.dist:check_requirements"
setup_requires = "setuptools.dist:check_requirements"
python_requires = "setuptools.dist:check_specifier"
entry_points = "setuptools.dist:check_entry_points"
test_suite = "setuptools.dist:check_test_suite"
zip_safe = "setuptools.dist:assert_bool"
package_data = "setuptools.dist:check_package_data"
exclude_package_data = "setuptools.dist:check_package_data"
include_package_data = "setuptools.dist:assert_bool"
packages = "setuptools.dist:check_packages"
dependency_links = "setuptools.dist:assert_string_list"
test_loader = "setuptools.dist:check_importable"
test_runner = "setuptools.dist:check_importable"
use_2to3 = "setuptools.dist:invalid_unless_false"

[project.entry-points."egg_info.writers"]
Expand Down
42 changes: 42 additions & 0 deletions setuptools/_path.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import contextlib
import os
import sys
from typing import Union

from more_itertools import unique_everseen


if sys.version_info >= (3, 9):
StrPath = Union[str, os.PathLike[str]] # Same as _typeshed.StrPath
else:
Expand Down Expand Up @@ -38,3 +42,41 @@ def normpath(filename: StrPath) -> str:
# See pkg_resources.normalize_path for notes about cygwin
file = os.path.abspath(filename) if sys.platform == 'cygwin' else filename
return os.path.normcase(os.path.realpath(os.path.normpath(file)))


@contextlib.contextmanager
def paths_on_pythonpath(paths):
"""
Add the indicated paths to the head of the PYTHONPATH environment
variable so that subprocesses will also see the packages at
these paths.
Do this in a context that restores the value on exit.
>>> getfixture('monkeypatch').setenv('PYTHONPATH', 'anything')
>>> with paths_on_pythonpath(['foo', 'bar']):
... assert 'foo' in os.environ['PYTHONPATH']
... assert 'anything' in os.environ['PYTHONPATH']
>>> os.environ['PYTHONPATH']
'anything'
>>> getfixture('monkeypatch').delenv('PYTHONPATH')
>>> with paths_on_pythonpath(['foo', 'bar']):
... assert 'foo' in os.environ['PYTHONPATH']
>>> os.environ.get('PYTHONPATH')
"""
nothing = object()
orig_pythonpath = os.environ.get('PYTHONPATH', nothing)
current_pythonpath = os.environ.get('PYTHONPATH', '')
try:
prefix = os.pathsep.join(unique_everseen(paths))
to_join = filter(None, [prefix, current_pythonpath])
new_path = os.pathsep.join(to_join)
if new_path:
os.environ['PYTHONPATH'] = new_path
yield
finally:
if orig_pythonpath is nothing:
os.environ.pop('PYTHONPATH', None)
else:
os.environ['PYTHONPATH'] = orig_pythonpath
250 changes: 0 additions & 250 deletions setuptools/command/test.py

This file was deleted.

1 change: 0 additions & 1 deletion setuptools/config/setupcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,6 @@ def parsers(self):
self._parse_requirements_list, "install_requires"
),
'setup_requires': self._parse_list_semicolon,
'tests_require': self._parse_list_semicolon,
'packages': self._parse_packages,
'entry_points': self._parse_file_in_root,
'py_modules': parse_list,
Expand Down
11 changes: 0 additions & 11 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ def check_entry_points(dist, attr, value):
raise DistutilsSetupError(e) from e


def check_test_suite(dist, attr, value):
if not isinstance(value, str):
raise DistutilsSetupError("test_suite must be a string")


def check_package_data(dist, attr, value):
"""Verify that value is a dictionary of package names to glob lists"""
if not isinstance(value, dict):
Expand Down Expand Up @@ -233,12 +228,6 @@ class Distribution(_Distribution):
EasyInstall and requests one of your extras, the corresponding
additional requirements will be installed if needed.
'test_suite' -- the name of a test suite to run for the 'test' command.
If the user runs 'python setup.py test', the package will be installed,
and the named test suite will be run. The format is the same as
would be used on a 'unittest.py' command line. That is, it is the
dotted name of an object to import and call to generate a test suite.
'package_data' -- a dictionary mapping package names to lists of filenames
or globs to use to find data files contained in the named packages.
If the dictionary has filenames or globs listed under '""' (the empty
Expand Down
1 change: 0 additions & 1 deletion setuptools/tests/config/setupcfg_examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ https://github.com/pallets/click/raw/6411f425fae545f42795665af4162006b36c5e4a/se
https://github.com/sqlalchemy/sqlalchemy/raw/533f5718904b620be8d63f2474229945d6f8ba5d/setup.cfg
https://github.com/pytest-dev/pluggy/raw/461ef63291d13589c4e21aa182cd1529257e9a0a/setup.cfg
https://github.com/pytest-dev/pytest/raw/c7be96dae487edbd2f55b561b31b68afac1dabe6/setup.cfg
https://github.com/tqdm/tqdm/raw/fc69d5dcf578f7c7986fa76841a6b793f813df35/setup.cfg
https://github.com/platformdirs/platformdirs/raw/7b7852128dd6f07511b618d6edea35046bd0c6ff/setup.cfg
https://github.com/pandas-dev/pandas/raw/bc17343f934a33dc231c8c74be95d8365537c376/setup.cfg
https://github.com/django/django/raw/4e249d11a6e56ca8feb4b055b681cec457ef3a3d/setup.cfg
Expand Down
Loading

0 comments on commit 4c0b9f3

Please sign in to comment.