Skip to content

Commit a768f8d

Browse files
authored
Merge pull request #1878 from jdufresne/deprecate-test-suite
Deprecate the test command
2 parents 1362c8c + cd84510 commit a768f8d

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

changelog.d/1878.change.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Formally deprecated the ``test`` command, with the recommendation that users migrate to ``tox``.

docs/setuptools.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ unless you need the associated ``setuptools`` feature.
346346
specified test suite, e.g. via ``setup.py test``. See the section on the
347347
`test`_ command below for more details.
348348

349+
New in 41.5.0: Deprecated the test command.
350+
349351
``tests_require``
350352
If your project's tests need one or more additional packages besides those
351353
needed to install it, you can use this option to specify them. It should
@@ -357,6 +359,8 @@ unless you need the associated ``setuptools`` feature.
357359
are run, but only downloaded to the project's setup directory if they're
358360
not already installed locally.
359361

362+
New in 41.5.0: Deprecated the test command.
363+
360364
.. _test_loader:
361365

362366
``test_loader``
@@ -380,6 +384,8 @@ unless you need the associated ``setuptools`` feature.
380384
as long as you use the ``tests_require`` option to ensure that the package
381385
containing the loader class is available when the ``test`` command is run.
382386

387+
New in 41.5.0: Deprecated the test command.
388+
383389
``eager_resources``
384390
A list of strings naming resources that should be extracted together, if
385391
any of them is needed, or if any C extensions included in the project are
@@ -2142,6 +2148,11 @@ distutils configuration file the option will be added to (or removed from).
21422148
``test`` - Build package and run a unittest suite
21432149
=================================================
21442150

2151+
.. warning::
2152+
``test`` is deprecated and will be removed in a future version. Users
2153+
looking for a generic test entry point independent of test runner are
2154+
encouraged to use `tox <https://tox.readthedocs.io>`_.
2155+
21452156
When doing test-driven development, or running automated builds that need
21462157
testing before they are deployed for downloading or use, it's often useful
21472158
to be able to run a project's unit tests without actually deploying the project
@@ -2187,6 +2198,8 @@ available:
21872198
If you did not set a ``test_suite`` in your ``setup()`` call, and do not
21882199
provide a ``--test-suite`` option, an error will occur.
21892200

2201+
New in 41.5.0: Deprecated the test command.
2202+
21902203

21912204
.. _upload:
21922205

setuptools/command/test.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __get__(self, obj, objtype=None):
7474
class test(Command):
7575
"""Command to run unit tests after in-place build"""
7676

77-
description = "run unit tests after in-place build"
77+
description = "run unit tests after in-place build (deprecated)"
7878

7979
user_options = [
8080
('test-module=', 'm', "Run 'test_suite' in specified module"),
@@ -214,6 +214,14 @@ def install_dists(dist):
214214
return itertools.chain(ir_d, tr_d, er_d)
215215

216216
def run(self):
217+
self.announce(
218+
"WARNING: Testing via this command is deprecated and will be "
219+
"removed in a future version. Users looking for a generic test "
220+
"entry point independent of test runner are encouraged to use "
221+
"tox.",
222+
log.WARN,
223+
)
224+
217225
installed_dists = self.install_dists(self.distribution)
218226

219227
cmd = ' '.join(self._argv)

setuptools/tests/test_test.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import unicode_literals
44

5+
import mock
56
from distutils import log
67
import os
78

@@ -124,3 +125,52 @@ def test_test(self):
124125
cmd.run()
125126
out, err = capfd.readouterr()
126127
assert out == 'Foo\n'
128+
129+
130+
@pytest.mark.usefixtures('sample_test')
131+
def test_warns_deprecation(capfd):
132+
params = dict(
133+
name='foo',
134+
packages=['name', 'name.space', 'name.space.tests'],
135+
namespace_packages=['name'],
136+
test_suite='name.space.tests.test_suite',
137+
use_2to3=True
138+
)
139+
dist = Distribution(params)
140+
dist.script_name = 'setup.py'
141+
cmd = test(dist)
142+
cmd.ensure_finalized()
143+
cmd.announce = mock.Mock()
144+
cmd.run()
145+
capfd.readouterr()
146+
msg = (
147+
"WARNING: Testing via this command is deprecated and will be "
148+
"removed in a future version. Users looking for a generic test "
149+
"entry point independent of test runner are encouraged to use "
150+
"tox."
151+
)
152+
cmd.announce.assert_any_call(msg, log.WARN)
153+
154+
155+
@pytest.mark.usefixtures('sample_test')
156+
def test_deprecation_stderr(capfd):
157+
params = dict(
158+
name='foo',
159+
packages=['name', 'name.space', 'name.space.tests'],
160+
namespace_packages=['name'],
161+
test_suite='name.space.tests.test_suite',
162+
use_2to3=True
163+
)
164+
dist = Distribution(params)
165+
dist.script_name = 'setup.py'
166+
cmd = test(dist)
167+
cmd.ensure_finalized()
168+
cmd.run()
169+
out, err = capfd.readouterr()
170+
msg = (
171+
"WARNING: Testing via this command is deprecated and will be "
172+
"removed in a future version. Users looking for a generic test "
173+
"entry point independent of test runner are encouraged to use "
174+
"tox.\n"
175+
)
176+
assert msg in err

0 commit comments

Comments
 (0)