pytest-runner-2.11.1/0000755000175000017500000000000013046712547015306 5ustar travistravis00000000000000pytest-runner-2.11.1/docs/0000755000175000017500000000000013046712547016236 5ustar travistravis00000000000000pytest-runner-2.11.1/docs/conf.py0000644000175000017500000000232613046712520017527 0ustar travistravis00000000000000#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import sys import subprocess if 'check_output' not in dir(subprocess): import subprocess32 as subprocess extensions = [ 'sphinx.ext.autodoc', 'rst.linker', ] # General information about the project. root = os.path.join(os.path.dirname(__file__), '..') setup_script = os.path.join(root, 'setup.py') fields = ['--name', '--version', '--url', '--author'] dist_info_cmd = [sys.executable, setup_script] + fields output_bytes = subprocess.check_output(dist_info_cmd, cwd=root) project, version, url, author = output_bytes.decode('utf-8').strip().split('\n') copyright = '2015-2017 ' + author # The full version, including alpha/beta/rc tags. release = version master_doc = 'index' link_files = { '../CHANGES.rst': dict( using=dict( GH='https://github.com', project=project, url=url, ), replace=[ dict( pattern=r"(Issue )?#(?P\d+)", url='{url}/issues/{issue}', ), dict( pattern=r"^(?m)((?Pv?\d+(\.\d+){1,2}))\n[-=]+\n", with_scm="{text}\n{rev[timestamp]:%d %b %Y}\n", ), dict( pattern=r"PEP[- ](?P\d+)", url='https://www.python.org/dev/peps/pep-{pep_number:0>4}/', ), ], ), } pytest-runner-2.11.1/docs/history.rst0000644000175000017500000000012113046712520020452 0ustar travistravis00000000000000:tocdepth: 2 .. _changes: History ******* .. include:: ../CHANGES (links).rst pytest-runner-2.11.1/docs/index.rst0000644000175000017500000000036313046712520020070 0ustar travistravis00000000000000Welcome to pytest-runner documentation! ======================================= .. toctree:: :maxdepth: 1 history .. include:: ../README.rst Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` pytest-runner-2.11.1/docs/requirements.txt0000644000175000017500000000001313046712520021503 0ustar travistravis00000000000000rst.linker pytest-runner-2.11.1/pytest_runner.egg-info/0000755000175000017500000000000013046712547021721 5ustar travistravis00000000000000pytest-runner-2.11.1/pytest_runner.egg-info/PKG-INFO0000644000175000017500000001327013046712547023021 0ustar travistravis00000000000000Metadata-Version: 1.1 Name: pytest-runner Version: 2.11.1 Summary: Invoke py.test as distutils command with dependency resolution Home-page: https://github.com/pytest-dev/pytest-runner Author: Jason R. Coombs Author-email: jaraco@jaraco.com License: UNKNOWN Description: .. image:: https://img.shields.io/pypi/v/pytest-runner.svg :target: https://pypi.org/project/pytest-runner .. image:: https://img.shields.io/pypi/pyversions/pytest-runner.svg .. image:: https://img.shields.io/pypi/dm/pytest-runner.svg .. image:: https://img.shields.io/travis/pytest-dev/pytest-runner/master.svg :target: http://travis-ci.org/pytest-dev/pytest-runner Setup scripts can use pytest-runner to add setup.py test support for pytest runner. License ======= License is indicated in the project metadata (typically one or more of the Trove classifiers). For more details, see `this explanation `_. Usage ----- - Add 'pytest-runner' to your 'setup_requires'. Pin to '>=2.0,<3dev' (or similar) to avoid pulling in incompatible versions. - Include 'pytest' and any other testing requirements to 'tests_require'. - Invoke tests with ``setup.py pytest``. - Pass ``--index-url`` to have test requirements downloaded from an alternate index URL (unnecessary if specified for easy_install in setup.cfg). - Pass additional py.test command-line options using ``--addopts``. - Set permanent options for the ``python setup.py pytest`` command (like ``index-url``) in the ``[pytest]`` section of ``setup.cfg``. - Set permanent options for the ``py.test`` run (like ``addopts`` or ``pep8ignore``) in the ``[pytest]`` section of ``pytest.ini`` or ``tox.ini`` or put them in the ``[tool:pytest]`` section of ``setup.cfg``. See `pytest issue 567 `_. - Optionally, set ``test=pytest`` in the ``[aliases]`` section of ``setup.cfg`` to cause ``python setup.py test`` to invoke pytest. Example ------- The most simple usage looks like this in setup.py:: setup( setup_requires=[ 'pytest-runner', ], tests_require=[ 'pytest', ], ) Additional dependencies require to run the tests (e.g. mock or pytest plugins) may be added to tests_require and will be downloaded and required by the session before invoking pytest. Follow `this search on github `_ for examples of real-world usage. Standalone Example ------------------ This technique is deprecated - if you have standalone scripts you wish to invoke with dependencies, `use rwt `_. Although ``pytest-runner`` is typically used to add pytest test runner support to maintained packages, ``pytest-runner`` may also be used to create standalone tests. Consider `this example failure `_, reported in `jsonpickle #117 `_ or `this MongoDB test `_ demonstrating a technique that works even when dependencies are required in the test. Either example file may be cloned or downloaded and simply run on any system with Python and Setuptools. It will download the specified dependencies and run the tests. Afterward, the the cloned directory can be removed and with it all trace of invoking the test. No other dependencies are needed and no system configuration is altered. Then, anyone trying to replicate the failure can do so easily and with all the power of pytest (rewritten assertions, rich comparisons, interactive debugging, extensibility through plugins, etc). As a result, the communication barrier for describing and replicating failures is made almost trivially low. Considerations -------------- Conditional Requirement ~~~~~~~~~~~~~~~~~~~~~~~ Because it uses Setuptools setup_requires, pytest-runner will install itself on every invocation of setup.py. In some cases, this causes delays for invocations of setup.py that will never invoke pytest-runner. To help avoid this contingency, consider requiring pytest-runner only when pytest is invoked:: needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv) pytest_runner = ['pytest-runner'] if needs_pytest else [] # ... setup( #... setup_requires=[ #... (other setup requirements) ] + pytest_runner, ) Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Framework :: Pytest pytest-runner-2.11.1/pytest_runner.egg-info/SOURCES.txt0000644000175000017500000000063313046712547023607 0ustar travistravis00000000000000.travis.yml CHANGES.rst LICENSE README.rst ptr.py pytest.ini setup.cfg setup.py tox.ini docs/conf.py docs/history.rst docs/index.rst docs/requirements.txt pytest_runner.egg-info/PKG-INFO pytest_runner.egg-info/SOURCES.txt pytest_runner.egg-info/dependency_links.txt pytest_runner.egg-info/entry_points.txt pytest_runner.egg-info/namespace_packages.txt pytest_runner.egg-info/top_level.txt tests/requirements.txtpytest-runner-2.11.1/pytest_runner.egg-info/dependency_links.txt0000644000175000017500000000000113046712547025767 0ustar travistravis00000000000000 pytest-runner-2.11.1/pytest_runner.egg-info/entry_points.txt0000644000175000017500000000007313046712547025217 0ustar travistravis00000000000000[distutils.commands] ptr = ptr:PyTest pytest = ptr:PyTest pytest-runner-2.11.1/pytest_runner.egg-info/namespace_packages.txt0000644000175000017500000000000113046712547026243 0ustar travistravis00000000000000 pytest-runner-2.11.1/pytest_runner.egg-info/top_level.txt0000644000175000017500000000000413046712547024445 0ustar travistravis00000000000000ptr pytest-runner-2.11.1/tests/0000755000175000017500000000000013046712547016450 5ustar travistravis00000000000000pytest-runner-2.11.1/tests/requirements.txt0000644000175000017500000000006213046712520021721 0ustar travistravis00000000000000pytest >= 2.8 subprocess32; python_version=="2.6" pytest-runner-2.11.1/.travis.yml0000644000175000017500000000203313046712520017404 0ustar travistravis00000000000000sudo: false language: python python: - 2.7 - 3.6 - nightly install: - pip install tox "setuptools>=28.2" script: - tox branches: except: - skeleton deploy: provider: pypi server: https://upload.pypi.org/legacy/ on: tags: true all_branches: true python: 3.6 user: jaraco distributions: dists skip_upload_docs: true password: secure: lZfYQx0ZrCf2FJ+348etKWfzTySB3BZYGd0ce5RFHN2BppcdkONyJfTs4rgdrFEn/WtOaKV3SkJYR09xvlr+4kbLibg7fXhueqZt0ZkhRBnoDE4SxCjICyFCmisG6O3zkrVosizch70/0MqseNanhgXOPhd5llCfQHIqLsa145BG4hM5kxAHPO3Rz2/HCObOTPe4HKj93RAK7lPIMZVN6omcWoG6ZB0QqK+i3LTUtmJ3gE6q/iHk3VF9cJs8xtn3hdo++Lhrboa2NIqf6fl8oxR1C24Wh8vBQ69uTNjmVnDFYMulTs5475jjgDBXPPgVz3CAqYAy/PI+NPw59ebK8MzlaMRK/h/xSrdhxW6K3WbBL71Dn2UGuejXHFC3IuCI832xwkuEupOcGLWz4r2uBnhbgXF63vZ2gYPqrCGHxvDpbtllTVyEeebP8BnFzZttxSn9rbhTP1O9Dn/9tRko8WskyXIR+/2JOA9KP5uT47yeHoFBBUS0GB1XdkGhBrJfQx2LhfHuI6bpzosMiMfJrVNZEg8k0I9XA0uwxDgZrdqKGMKBR6233MXiJg8NyUPRInCRGth4rufcq6kn+wsT9RvuSt9XOhGiYLwChjvHexUXrLGBgupu0Y80Oqcp3YkDG3WHUX++Z2zJSQovrb4BMdKS6Y4usQ8Df5SklIpMCf0= pytest-runner-2.11.1/CHANGES.rst0000644000175000017500000000373213046712520017104 0ustar travistravis000000000000002.11.1 ~~~~~~ * #28: Fix logic in marker evaluation. 2.11 ~~~~ * #27: Improved wording in the README around configuration for the distutils command and pytest proper. 2.10.1 ~~~~~~ * #21: Avoid mutating dictionary keys during iteration. 2.10 ~~~~ * #20: Leverage technique in `setuptools 794 `_ to populate PYTHONPATH during test runs such that Python subprocesses will have a dependency context comparable to the test runner. 2.9 ~~~ * Added Trove Classifier indicating this package is part of the pytest framework. 2.8 ~~~ * #16: Added a license file, required for membership to pytest-dev. * Releases are now made automatically by pushing a tagged release that passes tests on Python 3.5. 2.7 ~~~ * Moved hosting to Github. 2.6 ~~~ * Add support for un-named, environment-specific extras. 2.5.1 ~~~~~ * Restore Python 2.6 compatibility. 2.5 ~~~ * Moved hosting to `pytest-dev `_. 2.4 ~~~ * Added `documentation `_. * Use setuptools_scm for version management and file discovery. * Updated internal packaging technique. README is now included in the package metadata. 2.3 ~~~ * Use hgdistver for version management and file discovery. 2.2 ~~~ * Honor ``.eggs`` directory for transient downloads as introduced in Setuptools 7.0. 2.1 ~~~ * The preferred invocation is now the 'pytest' command. 2.0 ~~~ * Removed support for the alternate usage. The recommended usage (as a distutils command) is now the only supported usage. * Removed support for the --junitxml parameter to the ptr command. Clients should pass the same parameter (and all other py.test arguments) to py.test via the --addopts parameter. 1.1 ~~~ * Added support for --addopts to pass any arguments through to py.test. * Deprecated support for --junitxml. Use --addopts instead. --junitxml will be removed in 2.0. 1.0 ~~~ Initial implementation. pytest-runner-2.11.1/LICENSE0000644000175000017500000000207713046712520016310 0ustar travistravis00000000000000The MIT License (MIT) Copyright (c) 2011-2016 Jason R. Coombs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pytest-runner-2.11.1/README.rst0000644000175000017500000001023313046712520016763 0ustar travistravis00000000000000.. image:: https://img.shields.io/pypi/v/pytest-runner.svg :target: https://pypi.org/project/pytest-runner .. image:: https://img.shields.io/pypi/pyversions/pytest-runner.svg .. image:: https://img.shields.io/pypi/dm/pytest-runner.svg .. image:: https://img.shields.io/travis/pytest-dev/pytest-runner/master.svg :target: http://travis-ci.org/pytest-dev/pytest-runner Setup scripts can use pytest-runner to add setup.py test support for pytest runner. License ======= License is indicated in the project metadata (typically one or more of the Trove classifiers). For more details, see `this explanation `_. Usage ----- - Add 'pytest-runner' to your 'setup_requires'. Pin to '>=2.0,<3dev' (or similar) to avoid pulling in incompatible versions. - Include 'pytest' and any other testing requirements to 'tests_require'. - Invoke tests with ``setup.py pytest``. - Pass ``--index-url`` to have test requirements downloaded from an alternate index URL (unnecessary if specified for easy_install in setup.cfg). - Pass additional py.test command-line options using ``--addopts``. - Set permanent options for the ``python setup.py pytest`` command (like ``index-url``) in the ``[pytest]`` section of ``setup.cfg``. - Set permanent options for the ``py.test`` run (like ``addopts`` or ``pep8ignore``) in the ``[pytest]`` section of ``pytest.ini`` or ``tox.ini`` or put them in the ``[tool:pytest]`` section of ``setup.cfg``. See `pytest issue 567 `_. - Optionally, set ``test=pytest`` in the ``[aliases]`` section of ``setup.cfg`` to cause ``python setup.py test`` to invoke pytest. Example ------- The most simple usage looks like this in setup.py:: setup( setup_requires=[ 'pytest-runner', ], tests_require=[ 'pytest', ], ) Additional dependencies require to run the tests (e.g. mock or pytest plugins) may be added to tests_require and will be downloaded and required by the session before invoking pytest. Follow `this search on github `_ for examples of real-world usage. Standalone Example ------------------ This technique is deprecated - if you have standalone scripts you wish to invoke with dependencies, `use rwt `_. Although ``pytest-runner`` is typically used to add pytest test runner support to maintained packages, ``pytest-runner`` may also be used to create standalone tests. Consider `this example failure `_, reported in `jsonpickle #117 `_ or `this MongoDB test `_ demonstrating a technique that works even when dependencies are required in the test. Either example file may be cloned or downloaded and simply run on any system with Python and Setuptools. It will download the specified dependencies and run the tests. Afterward, the the cloned directory can be removed and with it all trace of invoking the test. No other dependencies are needed and no system configuration is altered. Then, anyone trying to replicate the failure can do so easily and with all the power of pytest (rewritten assertions, rich comparisons, interactive debugging, extensibility through plugins, etc). As a result, the communication barrier for describing and replicating failures is made almost trivially low. Considerations -------------- Conditional Requirement ~~~~~~~~~~~~~~~~~~~~~~~ Because it uses Setuptools setup_requires, pytest-runner will install itself on every invocation of setup.py. In some cases, this causes delays for invocations of setup.py that will never invoke pytest-runner. To help avoid this contingency, consider requiring pytest-runner only when pytest is invoked:: needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv) pytest_runner = ['pytest-runner'] if needs_pytest else [] # ... setup( #... setup_requires=[ #... (other setup requirements) ] + pytest_runner, ) pytest-runner-2.11.1/ptr.py0000644000175000017500000001264113046712520016460 0ustar travistravis00000000000000""" Implementation """ import os as _os import shlex as _shlex import contextlib as _contextlib import sys as _sys import operator as _operator import itertools as _itertools try: # ensure that map has the same meaning on Python 2 from future_builtins import map except ImportError: pass import pkg_resources import setuptools.command.test as orig @_contextlib.contextmanager def _save_argv(repl=None): saved = _sys.argv[:] if repl is not None: _sys.argv[:] = repl try: yield saved finally: _sys.argv[:] = saved @_contextlib.contextmanager def null(): yield class PyTest(orig.test): """ >>> import setuptools >>> dist = setuptools.Distribution() >>> cmd = PyTest(dist) """ user_options = [ ('extras', None, "Install (all) setuptools extras when running tests"), ('index-url=', None, "Specify an index url from which to retrieve " "dependencies"), ('allow-hosts=', None, "Whitelist of comma-separated hosts to allow " "when retrieving dependencies"), ('addopts=', None, "Additional options to be passed verbatim to the " "pytest runner") ] def initialize_options(self): self.extras = False self.index_url = None self.allow_hosts = None self.addopts = [] def finalize_options(self): if self.addopts: self.addopts = _shlex.split(self.addopts) @staticmethod def marker_passes(marker): """ Given an environment marker, return True if the marker is valid and matches this environment. """ return ( marker and not pkg_resources.invalid_marker(marker) and pkg_resources.evaluate_marker(marker) ) @staticmethod def _install_dists_compat(dist): """ Copy of install_dists from setuptools 27.3.0. """ ir_d = dist.fetch_build_eggs(dist.install_requires or []) tr_d = dist.fetch_build_eggs(dist.tests_require or []) return _itertools.chain(ir_d, tr_d) def install_dists(self, dist): """ Extend install_dists to include extras support """ i_d = getattr(orig.test, 'install_dists', self._install_dists_compat) return _itertools.chain(i_d(dist), self.install_extra_dists(dist)) def install_extra_dists(self, dist): """ Install extras that are indicated by markers or install all extras if '--extras' is indicated. """ extras_require = dist.extras_require or {} spec_extras = ( (spec.partition(':'), reqs) for spec, reqs in extras_require.items() ) matching_extras = ( reqs for (name, sep, marker), reqs in spec_extras # never include extras that fail to pass marker eval if self.marker_passes(marker) # include unnamed extras or all if self.extras indicated and (not name or self.extras) ) results = list(map(dist.fetch_build_eggs, matching_extras)) return _itertools.chain.from_iterable(results) @staticmethod def paths_on_pythonpath(paths): """ Backward compatibility for paths_on_pythonpath; Returns a null context if paths_on_pythonpath is not implemented in orig.test. Note that this also means that the paths iterable is never consumed, which incidentally means that the None values from dist.fetch_build_eggs in older Setuptools will be disregarded. """ try: return orig.test.paths_on_pythonpath(paths) except AttributeError: return null() def _super_run(self): if hasattr(orig.test, 'install_dists'): return orig.test.run(self) # for backward compatibility with setuptools < 27.3 installed_dists = self.install_dists(self.distribution) if self.dry_run: self.announce('skipping tests (dry run)') return paths = map(_operator.attrgetter('location'), installed_dists) with self.paths_on_pythonpath(paths): self.with_project_on_sys_path(self.run_tests) def run(self): """ Override run to ensure requirements are available in this session (but don't install them anywhere). """ self._build_egg_fetcher() self._super_run() if self.result_code: raise SystemExit(self.result_code) return self.result_code def _build_egg_fetcher(self): """Build an egg fetcher that respects index_url and allow_hosts""" # modified from setuptools.dist:Distribution.fetch_build_egg from setuptools.command.easy_install import easy_install main_dist = self.distribution # construct a fake distribution to store the args for easy_install dist = main_dist.__class__({'script_args': ['easy_install']}) dist.parse_config_files() opts = dist.get_option_dict('easy_install') keep = ( 'find_links', 'site_dirs', 'index_url', 'optimize', 'site_dirs', 'allow_hosts' ) for key in list(opts.keys()): if key not in keep: del opts[key] # don't use any other settings if main_dist.dependency_links: links = main_dist.dependency_links[:] if 'find_links' in opts: links = opts['find_links'][1].split() + links opts['find_links'] = ('setup', links) if self.allow_hosts: opts['allow_hosts'] = ('test', self.allow_hosts) if self.index_url: opts['index_url'] = ('test', self.index_url) install_dir_func = getattr(dist, 'get_egg_cache_dir', _os.getcwd) install_dir = install_dir_func() cmd = easy_install( dist, args=["x"], install_dir=install_dir, exclude_scripts=True, always_copy=False, build_directory=None, editable=False, upgrade=False, multi_version=True, no_report = True ) cmd.ensure_finalized() main_dist._egg_fetcher = cmd @property def _argv(self): return ['pytest'] + self.addopts def run_tests(self): """ Invoke pytest, replacing argv. """ with _save_argv(_sys.argv[:1] + self.addopts): self.result_code = __import__('pytest').main() pytest-runner-2.11.1/pytest.ini0000644000175000017500000000015413046712520017326 0ustar travistravis00000000000000[pytest] norecursedirs=dist build .tox addopts=--doctest-modules doctest_optionflags=ALLOW_UNICODE ELLIPSIS pytest-runner-2.11.1/setup.cfg0000644000175000017500000000023213046712547017124 0ustar travistravis00000000000000[aliases] release = dists upload dists = clean --all sdist bdist_wheel [wheel] universal = 1 [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 pytest-runner-2.11.1/setup.py0000644000175000017500000000221313046712520017005 0ustar travistravis00000000000000#!/usr/bin/env python # Project skeleton maintained at https://github.com/jaraco/skeleton import io import setuptools with io.open('README.rst', encoding='utf-8') as readme: long_description = readme.read() name = 'pytest-runner' description = 'Invoke py.test as distutils command with dependency resolution' params = dict( name=name, use_scm_version=True, author="Jason R. Coombs", author_email="jaraco@jaraco.com", description=description or name, long_description=long_description, url="https://github.com/pytest-dev/" + name, namespace_packages=name.split('.')[:-1], py_modules=['ptr'], install_requires=[ ], extras_require={ }, setup_requires=[ 'setuptools_scm>=1.15.0', ], classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Framework :: Pytest", ], entry_points = { 'distutils.commands': [ 'ptr = ptr:PyTest', 'pytest = ptr:PyTest', ], }, ) if __name__ == '__main__': setuptools.setup(**params) pytest-runner-2.11.1/tox.ini0000644000175000017500000000013313046712520016605 0ustar travistravis00000000000000[testenv] deps = -rtests/requirements.txt commands = py.test {posargs} usedevelop = True pytest-runner-2.11.1/PKG-INFO0000644000175000017500000001327013046712547016406 0ustar travistravis00000000000000Metadata-Version: 1.1 Name: pytest-runner Version: 2.11.1 Summary: Invoke py.test as distutils command with dependency resolution Home-page: https://github.com/pytest-dev/pytest-runner Author: Jason R. Coombs Author-email: jaraco@jaraco.com License: UNKNOWN Description: .. image:: https://img.shields.io/pypi/v/pytest-runner.svg :target: https://pypi.org/project/pytest-runner .. image:: https://img.shields.io/pypi/pyversions/pytest-runner.svg .. image:: https://img.shields.io/pypi/dm/pytest-runner.svg .. image:: https://img.shields.io/travis/pytest-dev/pytest-runner/master.svg :target: http://travis-ci.org/pytest-dev/pytest-runner Setup scripts can use pytest-runner to add setup.py test support for pytest runner. License ======= License is indicated in the project metadata (typically one or more of the Trove classifiers). For more details, see `this explanation `_. Usage ----- - Add 'pytest-runner' to your 'setup_requires'. Pin to '>=2.0,<3dev' (or similar) to avoid pulling in incompatible versions. - Include 'pytest' and any other testing requirements to 'tests_require'. - Invoke tests with ``setup.py pytest``. - Pass ``--index-url`` to have test requirements downloaded from an alternate index URL (unnecessary if specified for easy_install in setup.cfg). - Pass additional py.test command-line options using ``--addopts``. - Set permanent options for the ``python setup.py pytest`` command (like ``index-url``) in the ``[pytest]`` section of ``setup.cfg``. - Set permanent options for the ``py.test`` run (like ``addopts`` or ``pep8ignore``) in the ``[pytest]`` section of ``pytest.ini`` or ``tox.ini`` or put them in the ``[tool:pytest]`` section of ``setup.cfg``. See `pytest issue 567 `_. - Optionally, set ``test=pytest`` in the ``[aliases]`` section of ``setup.cfg`` to cause ``python setup.py test`` to invoke pytest. Example ------- The most simple usage looks like this in setup.py:: setup( setup_requires=[ 'pytest-runner', ], tests_require=[ 'pytest', ], ) Additional dependencies require to run the tests (e.g. mock or pytest plugins) may be added to tests_require and will be downloaded and required by the session before invoking pytest. Follow `this search on github `_ for examples of real-world usage. Standalone Example ------------------ This technique is deprecated - if you have standalone scripts you wish to invoke with dependencies, `use rwt `_. Although ``pytest-runner`` is typically used to add pytest test runner support to maintained packages, ``pytest-runner`` may also be used to create standalone tests. Consider `this example failure `_, reported in `jsonpickle #117 `_ or `this MongoDB test `_ demonstrating a technique that works even when dependencies are required in the test. Either example file may be cloned or downloaded and simply run on any system with Python and Setuptools. It will download the specified dependencies and run the tests. Afterward, the the cloned directory can be removed and with it all trace of invoking the test. No other dependencies are needed and no system configuration is altered. Then, anyone trying to replicate the failure can do so easily and with all the power of pytest (rewritten assertions, rich comparisons, interactive debugging, extensibility through plugins, etc). As a result, the communication barrier for describing and replicating failures is made almost trivially low. Considerations -------------- Conditional Requirement ~~~~~~~~~~~~~~~~~~~~~~~ Because it uses Setuptools setup_requires, pytest-runner will install itself on every invocation of setup.py. In some cases, this causes delays for invocations of setup.py that will never invoke pytest-runner. To help avoid this contingency, consider requiring pytest-runner only when pytest is invoked:: needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv) pytest_runner = ['pytest-runner'] if needs_pytest else [] # ... setup( #... setup_requires=[ #... (other setup requirements) ] + pytest_runner, ) Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Framework :: Pytest