diff options
author | Thomas Grainger <tagrain@gmail.com> | 2019-07-03 16:42:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-03 16:42:53 +0100 |
commit | 2b9522e9da15107bf3a96083e0221ad6cce47bb6 (patch) | |
tree | f98c4a29942a48126329a34823cfabd98fd9e806 /doc/en/goodpractices.rst | |
parent | 528ee3e1c5b461c91948632aadd835ede83cc50b (diff) | |
download | pytest-2b9522e9da15107bf3a96083e0221ad6cce47bb6.tar.gz |
remove documentation about setuptools integration Refs #5534
integrating with `python setup.py test` is not good practice!
Diffstat (limited to 'doc/en/goodpractices.rst')
-rw-r--r-- | doc/en/goodpractices.rst | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/doc/en/goodpractices.rst b/doc/en/goodpractices.rst index 2314c0066..9622cc766 100644 --- a/doc/en/goodpractices.rst +++ b/doc/en/goodpractices.rst @@ -219,101 +219,4 @@ against your source code checkout, helping to detect packaging glitches. -Integrating with setuptools / ``python setup.py test`` / ``pytest-runner`` --------------------------------------------------------------------------- - -You can integrate test runs into your setuptools based project -with the `pytest-runner <https://pypi.org/project/pytest-runner/>`_ plugin. - -Add this to ``setup.py`` file: - -.. code-block:: python - - from setuptools import setup - - setup( - # ..., - setup_requires=["pytest-runner", ...], - tests_require=["pytest", ...], - # ..., - ) - - -And create an alias into ``setup.cfg`` file: - - -.. code-block:: ini - - [aliases] - test=pytest - -If you now type:: - - python setup.py test - -this will execute your tests using ``pytest-runner``. As this is a -standalone version of ``pytest`` no prior installation whatsoever is -required for calling the test command. You can also pass additional -arguments to pytest such as your test directory or other -options using ``--addopts``. - -You can also specify other pytest-ini options in your ``setup.cfg`` file -by putting them into a ``[tool:pytest]`` section: - -.. code-block:: ini - - [tool:pytest] - addopts = --verbose - python_files = testing/*/*.py - - -Manual Integration -^^^^^^^^^^^^^^^^^^ - -If for some reason you don't want/can't use ``pytest-runner``, you can write -your own setuptools Test command for invoking pytest. - -.. code-block:: python - - import sys - - from setuptools.command.test import test as TestCommand - - - class PyTest(TestCommand): - user_options = [("pytest-args=", "a", "Arguments to pass to pytest")] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = "" - - def run_tests(self): - import shlex - - # import here, cause outside the eggs aren't loaded - import pytest - - errno = pytest.main(shlex.split(self.pytest_args)) - sys.exit(errno) - - - setup( - # ..., - tests_require=["pytest"], - cmdclass={"pytest": PyTest}, - ) - -Now if you run:: - - python setup.py test - -this will download ``pytest`` if needed and then run your tests -as you would expect it to. You can pass a single string of arguments -using the ``--pytest-args`` or ``-a`` command-line option. For example:: - - python setup.py test -a "--durations=5" - -is equivalent to running ``pytest --durations=5``. - - .. include:: links.inc |