Skip to content

Commit 800227c

Browse files
committed
remove python setup.py test
Removed the "python setup.py test" feature in favor of a straight run of "tox". Per Pypa / pytest developers, "setup.py" commands are in general headed towards deprecation in favor of tox. The tox.ini script has been updated such that running "tox" with no arguments will perform a single run of the test suite against the default installed Python interpreter. .. seealso:: pypa/setuptools#1684 pytest-dev/pytest#5534 Fixes: #303 Change-Id: I345fd46f8911a71c039adf2d51937175142db793
1 parent 9a7d70a commit 800227c

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

doc/build/unreleased/303.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. change::
2+
:tags: bug, setup
3+
:tickets: 303
4+
5+
Removed the "python setup.py test" feature in favor of a straight run of
6+
"tox". Per Pypa / pytest developers, "setup.py" commands are in general
7+
headed towards deprecation in favor of tox. The tox.ini script has been
8+
updated such that running "tox" with no arguments will perform a single run
9+
of the test suite against the default installed Python interpreter.
10+
11+
.. seealso::
12+
13+
https://github.com/pypa/setuptools/issues/1684
14+
15+
https://github.com/pytest-dev/pytest/issues/5534

setup.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,19 @@
1919
install_requires = ["MarkupSafe>=0.9.2"]
2020

2121

22-
class PyTest(TestCommand):
23-
user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]
24-
25-
def initialize_options(self):
26-
TestCommand.initialize_options(self)
27-
self.pytest_args = []
28-
29-
def finalize_options(self):
30-
TestCommand.finalize_options(self)
31-
self.test_args = []
32-
self.test_suite = True
22+
class UseTox(TestCommand):
23+
RED = 31
24+
RESET_SEQ = "\033[0m"
25+
BOLD_SEQ = "\033[1m"
26+
COLOR_SEQ = "\033[1;%dm"
3327

3428
def run_tests(self):
35-
# import here, cause outside the eggs aren't loaded
36-
import pytest
37-
38-
errno = pytest.main(self.pytest_args)
39-
sys.exit(errno)
29+
sys.stderr.write(
30+
"%s%spython setup.py test is deprecated by pypa. Please invoke "
31+
"'tox' with no arguments for a basic test run.\n%s"
32+
% (self.COLOR_SEQ % self.RED, self.BOLD_SEQ, self.RESET_SEQ)
33+
)
34+
sys.exit(1)
4035

4136

4237
setup(
@@ -67,11 +62,9 @@ def run_tests(self):
6762
},
6863
license="MIT",
6964
packages=find_packages(".", exclude=["examples*", "test*"]),
70-
tests_require=["pytest", "mock"],
71-
cmdclass={"test": PyTest},
65+
cmdclass={"test": UseTox},
7266
zip_safe=False,
7367
install_requires=install_requires,
74-
extras_require={},
7568
entry_points="""
7669
[python.templating.engines]
7770
mako = mako.ext.turbogears:TGPlugin

tox.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{27,34,35,36,37,38}
2+
envlist = py
33

44
[testenv]
55
cov_args=--cov=mako --cov-report term --cov-report xml
@@ -20,9 +20,8 @@ setenv=
2020
commands=py.test {env:COVERAGE:} {posargs}
2121

2222

23-
# thanks to https://julien.danjou.info/the-best-flake8-extensions/
2423
[testenv:pep8]
25-
basepython = python3.7
24+
basepython = python3
2625
deps=
2726
flake8
2827
flake8-import-order

0 commit comments

Comments
 (0)