Skip to content

Commit

Permalink
Remove setup.py test
Browse files Browse the repository at this point in the history
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.

Fixes: #157
Change-Id: Iacfd486be3e76d3531422ead3ebadf4ecebb806f
  • Loading branch information
zzzeek committed Sep 20, 2019
1 parent c732ebc commit 04deeec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
16 changes: 16 additions & 0 deletions docs/build/unreleased/157.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. change::
:tags: bug, setup
:tickets: 157

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::

https://github.com/pypa/setuptools/issues/1684

https://github.com/pytest-dev/pytest/issues/5534

30 changes: 12 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,19 @@
from setuptools.command.test import test as TestCommand


class PyTest(TestCommand):
user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]

def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []

def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
class UseTox(TestCommand):
RED = 31
RESET_SEQ = "\033[0m"
BOLD_SEQ = "\033[1m"
COLOR_SEQ = "\033[1;%dm"

def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest

errno = pytest.main(self.pytest_args)
sys.exit(errno)
sys.stderr.write(
"%s%spython setup.py test is deprecated by pypa. Please invoke "
"'tox' with no arguments for a basic test run.\n%s"
% (self.COLOR_SEQ % self.RED, self.BOLD_SEQ, self.RESET_SEQ)
)
sys.exit(1)


v = open(os.path.join(os.path.dirname(__file__), "dogpile", "__init__.py"))
Expand Down Expand Up @@ -57,6 +52,5 @@ def run_tests(self):
""",
zip_safe=False,
install_requires=["decorator>=4.0.0"],
tests_require=["pytest", "pytest-cov", "mock", "Mako"],
cmdclass={"test": PyTest},
cmdclass={"test": UseTox},
)
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[tox]
minversion=1.8.dev1
envlist = py{27,35,36,37}
envlist = py

[testenv]
cov_args=--cov=dogpile --cov-append --cov-report term --cov-report xml
Expand Down Expand Up @@ -46,7 +45,7 @@ usedevelop=True

# thanks to https://julien.danjou.info/the-best-flake8-extensions/
[testenv:pep8]
basepython = python3.7
basepython = python3
deps=
flake8
flake8-import-order
Expand Down

0 comments on commit 04deeec

Please sign in to comment.