././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1701651796.7926166 pytest-runner-6.0.1/0000755252176402575230000000000014533222525015232 5ustar00jaracoprimarygroup././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/.coveragerc0000644252176402575230000000014314533222360017346 0ustar00jaracoprimarygroup[run] omit = # leading `*/` for pytest-dev/pytest-cov#456 */.tox/* [report] show_missing = True ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/.editorconfig0000644252176402575230000000033014533222360017700 0ustar00jaracoprimarygrouproot = true [*] charset = utf-8 indent_style = tab indent_size = 4 insert_final_newline = true end_of_line = lf [*.py] indent_style = space max_line_length = 88 [*.{yml,yaml}] indent_style = space indent_size = 2 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/.flake80000644252176402575230000000021014533222360016373 0ustar00jaracoprimarygroup[flake8] max-line-length = 88 # jaraco/skeleton#34 max-complexity = 10 extend-ignore = # Black creates whitespace before colon E203 ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1701651796.788807 pytest-runner-6.0.1/.github/0000755252176402575230000000000014533222525016572 5ustar00jaracoprimarygroup././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701650902.0 pytest-runner-6.0.1/.github/FUNDING.yml0000644252176402575230000000003514533220726020406 0ustar00jaracoprimarygrouptidelift: pypi/pytest-runner ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701650902.0 pytest-runner-6.0.1/.github/dependabot.yml0000644252176402575230000000022414533220726021421 0ustar00jaracoprimarygroupversion: 2 updates: - package-ecosystem: "pip" directory: "/" schedule: interval: "daily" allow: - dependency-type: "all" ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1701651796.7890518 pytest-runner-6.0.1/.github/workflows/0000755252176402575230000000000014533222525020627 5ustar00jaracoprimarygroup././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/.github/workflows/main.yml0000644252176402575230000000210014533222360022264 0ustar00jaracoprimarygroupname: tests on: [push, pull_request] jobs: test: strategy: matrix: python: - 3.7 - 3.9 - "3.10" platform: - ubuntu-latest - macos-latest - windows-latest runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} - name: Install tox run: | python -m pip install tox - name: Run tests run: tox release: needs: test if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v2 with: python-version: "3.10" - name: Install tox run: | python -m pip install tox - name: Release run: tox -e release env: TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/.pre-commit-config.yaml0000644252176402575230000000012114533222360021502 0ustar00jaracoprimarygrouprepos: - repo: https://github.com/psf/black rev: 22.1.0 hooks: - id: black ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/.readthedocs.yml0000644252176402575230000000011714533222360020314 0ustar00jaracoprimarygroupversion: 2 python: install: - path: . extra_requirements: - docs ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651705.0 pytest-runner-6.0.1/CHANGES.rst0000644252176402575230000001144514533222371017040 0ustar00jaracoprimarygroupv6.0.1 ====== * Updated Trove classifier to indicate this project is inactive. v6.0.0 ====== * #49: Dropped workaround for older setuptools versions. * Require Python 3.7. v5.3.2 ====== * #58: Fixed syntax issue in changelog. v5.3.1 ====== * Refreshed package metadata. v5.3.0 ====== * Require Python 3.6 or later. * Refreshed package metadata. 5.2 === * #50: This project is deprecated. 5.1 === * #49: Surgically restore support for older setuptools versions. 5.0 === * #42: Prefer pyproject.toml * Refresh package metadata. * This release now intentionally introduces the changes unintionally brought about in 4.5 and 4.3, where the adoption of declarative config adds a new requirement on setuptools 30.4 or later. On systems running older setuptools, installation of pytest-runner via ``easy_install`` (or ``setup_requires``), will result in a ``DistributionNotFound`` exception. All projects should pin to ``pytest-runner < 5`` or upgrade the environment to ``setuptools >= 30.4`` (prior to invoking setup.py). 4.5.1 ===== * #48: Revert changes from 4.5 - restoring project to the state at 4.4. 4.5 === (Pulled from PyPI due to #43 and #48) * Packaging (skeleton) refresh, including adoption of `black `_ for style. 4.4 === * #43: Detect condition where declarative config will cause errors and emit a UserWarning with guidance on necessary actions. 4.3.1 ===== * #43: Re-release of 4.2 to supersede the 4.3 release which proved to be backward-incompatible in that it requires setuptools 30.4 or possibly later (to install). In the future, a backward-incompatible release will re-release these changes. For projects including pytest-runner, particularly as ``setup_requires``, if support for older setuptools is required, please pin to ``pytest-runner < 5``. 4.3 === (Pulled from PyPI due to #43) * #42: Update project metadata, including pyproject.toml declaration. 4.2 === * #40: Remove declared dependency and instead assert it at run time. 4.1 === * #40: Declare dependency on Setuptools in package metadata. 4.0 === * Drop support for Setuptools before Setuptools 27.3.0. 3.0.1 ===== * #38: Fixed AttributeError when running with ``--dry-run``. ``PyTest.run()`` no longer stores nor returns the result code. Based on the commit message for `840ff4c `_, nothing has ever relied on that value. 3.0 === * Dropped support for Python 2.6 and 3.1. 2.12.2 ====== * #33: Packaging refresh. 2.12.1 ====== * #32: Fix support for ``dependency_links``. 2.12 ==== * #30: Rework support for ``--allow-hosts`` and ``--index-url``, removing dependence on ``setuptools.Distribution``'s private member. Additionally corrects logic in marker evaluation along with unit tests! 2.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. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/LICENSE0000644252176402575230000000203214533222360016231 0ustar00jaracoprimarygroupCopyright 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. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1701651796.7925143 pytest-runner-6.0.1/PKG-INFO0000644252176402575230000001617614533222525016342 0ustar00jaracoprimarygroupMetadata-Version: 2.1 Name: pytest-runner Version: 6.0.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 Classifier: Development Status :: 7 - Inactive Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Framework :: Pytest Requires-Python: >=3.7 License-File: LICENSE Provides-Extra: testing Requires-Dist: pytest>=6; extra == "testing" Requires-Dist: pytest-checkdocs>=2.4; extra == "testing" Requires-Dist: pytest-flake8; extra == "testing" Requires-Dist: pytest-black>=0.3.7; platform_python_implementation != "PyPy" and extra == "testing" Requires-Dist: pytest-cov; extra == "testing" Requires-Dist: pytest-mypy>=0.9.1; platform_python_implementation != "PyPy" and extra == "testing" Requires-Dist: pytest-enabler>=1.0.1; extra == "testing" Requires-Dist: pytest-virtualenv; extra == "testing" Requires-Dist: types-setuptools; extra == "testing" Provides-Extra: docs Requires-Dist: sphinx; extra == "docs" Requires-Dist: jaraco.packaging>=9; extra == "docs" Requires-Dist: rst.linker>=1.9; extra == "docs" Requires-Dist: jaraco.tidelift>=1.4; extra == "docs" .. image:: https://img.shields.io/pypi/v/pytest-runner.svg :target: `PyPI link`_ .. image:: https://img.shields.io/pypi/pyversions/pytest-runner.svg :target: `PyPI link`_ .. _PyPI link: https://pypi.org/project/pytest-runner .. image:: https://github.com/pytest-dev/pytest-runner/workflows/tests/badge.svg :target: https://github.com/pytest-dev/pytest-runner/actions?query=workflow%3A%22tests%22 :alt: tests .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black :alt: Code style: Black .. .. image:: https://readthedocs.org/projects/skeleton/badge/?version=latest .. :target: https://skeleton.readthedocs.io/en/latest/?badge=latest .. image:: https://img.shields.io/badge/skeleton-2022-informational :target: https://blog.jaraco.com/skeleton .. image:: https://tidelift.com/badges/package/pypi/pytest-runner :target: https://tidelift.com/subscription/pkg/pypi-pytest-runner?utm_source=pypi-pytest-runner&utm_medium=readme Setup scripts can use pytest-runner to add setup.py test support for pytest runner. Deprecation Notice ================== pytest-runner depends on deprecated features of setuptools and relies on features that break security mechanisms in pip. For example 'setup_requires' and 'tests_require' bypass ``pip --require-hashes``. See also `pypa/setuptools#1684 `_. It is recommended that you: - Remove ``'pytest-runner'`` from your ``setup_requires``, preferably removing the ``setup_requires`` option. - Remove ``'pytest'`` and any other testing requirements from ``tests_require``, preferably removing the ``tests_requires`` option. - Select a tool to bootstrap and then run tests such as tox. 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 pip-run `_. 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, ) For Enterprise ============== Available as part of the Tidelift Subscription. This project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use. `Learn more `_. Security Contact ================ To report a security vulnerability, please use the `Tidelift security contact `_. Tidelift will coordinate the fix and disclosure. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/README.rst0000644252176402575230000001345614533222360016727 0ustar00jaracoprimarygroup.. image:: https://img.shields.io/pypi/v/pytest-runner.svg :target: `PyPI link`_ .. image:: https://img.shields.io/pypi/pyversions/pytest-runner.svg :target: `PyPI link`_ .. _PyPI link: https://pypi.org/project/pytest-runner .. image:: https://github.com/pytest-dev/pytest-runner/workflows/tests/badge.svg :target: https://github.com/pytest-dev/pytest-runner/actions?query=workflow%3A%22tests%22 :alt: tests .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black :alt: Code style: Black .. .. image:: https://readthedocs.org/projects/skeleton/badge/?version=latest .. :target: https://skeleton.readthedocs.io/en/latest/?badge=latest .. image:: https://img.shields.io/badge/skeleton-2022-informational :target: https://blog.jaraco.com/skeleton .. image:: https://tidelift.com/badges/package/pypi/pytest-runner :target: https://tidelift.com/subscription/pkg/pypi-pytest-runner?utm_source=pypi-pytest-runner&utm_medium=readme Setup scripts can use pytest-runner to add setup.py test support for pytest runner. Deprecation Notice ================== pytest-runner depends on deprecated features of setuptools and relies on features that break security mechanisms in pip. For example 'setup_requires' and 'tests_require' bypass ``pip --require-hashes``. See also `pypa/setuptools#1684 `_. It is recommended that you: - Remove ``'pytest-runner'`` from your ``setup_requires``, preferably removing the ``setup_requires`` option. - Remove ``'pytest'`` and any other testing requirements from ``tests_require``, preferably removing the ``tests_requires`` option. - Select a tool to bootstrap and then run tests such as tox. 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 pip-run `_. 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, ) For Enterprise ============== Available as part of the Tidelift Subscription. This project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use. `Learn more `_. Security Contact ================ To report a security vulnerability, please use the `Tidelift security contact `_. Tidelift will coordinate the fix and disclosure. ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1701651796.789649 pytest-runner-6.0.1/docs/0000755252176402575230000000000014533222525016162 5ustar00jaracoprimarygroup././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/docs/conf.py0000644252176402575230000000232114533222360017454 0ustar00jaracoprimarygroup#!/usr/bin/env python3 # -*- coding: utf-8 -*- extensions = ['sphinx.ext.autodoc', 'jaraco.packaging.sphinx', 'rst.linker'] master_doc = "index" link_files = { '../CHANGES.rst': dict( using=dict(GH='https://github.com'), replace=[ dict( pattern=r'(Issue #|\B#)(?P\d+)', url='{package_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}/', ), dict( pattern=r'Setuptools #(?P\d+)', url='https://github.com/pypa/setuptools' '/issues/{setuptools_issue}/', ), ], ) } # Be strict about any broken references: nitpicky = True # Include Python intersphinx mapping to prevent failures # jaraco/skeleton#51 extensions += ['sphinx.ext.intersphinx'] intersphinx_mapping = { 'python': ('https://docs.python.org/3', None), } extensions += ['jaraco.tidelift'] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/docs/history.rst0000644252176402575230000000012114533222360020404 0ustar00jaracoprimarygroup:tocdepth: 2 .. _changes: History ******* .. include:: ../CHANGES (links).rst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651543.0 pytest-runner-6.0.1/docs/index.rst0000644252176402575230000000041114533222127020015 0ustar00jaracoprimarygroupWelcome to |project| documentation! =================================== .. toctree:: :maxdepth: 1 history .. tidelift-referral-banner:: .. include:: ../README.rst Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/mypy.ini0000644252176402575230000000004514533222360016725 0ustar00jaracoprimarygroup[mypy] ignore_missing_imports = True ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1701651796.7899253 pytest-runner-6.0.1/ptr/0000755252176402575230000000000014533222525016037 5ustar00jaracoprimarygroup././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701650902.0 pytest-runner-6.0.1/ptr/__init__.py0000644252176402575230000001511214533220726020151 0ustar00jaracoprimarygroup""" 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 import warnings as _warnings import pkg_resources import setuptools.command.test as orig from setuptools import Distribution @_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 class CustomizedDist(Distribution): allow_hosts = None index_url = None def fetch_build_egg(self, req): """Specialized version of Distribution.fetch_build_egg that respects respects allow_hosts and index_url.""" from setuptools.command.easy_install import easy_install dist = Distribution({'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): if key not in keep: del opts[key] # don't use any other settings if self.dependency_links: links = self.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(self, '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, user=False, ) cmd.ensure_finalized() return cmd.easy_install(req) 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 = [] self.ensure_setuptools_version() @staticmethod def ensure_setuptools_version(): """ Due to the fact that pytest-runner is often required (via setup-requires directive) by toolchains that never invoke it (i.e. they're only installing the package, not testing it), instead of declaring the dependency in the package metadata, assert the requirement at run time. """ pkg_resources.require('setuptools>=27.3') 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 ( not marker or not pkg_resources.invalid_marker(marker) and pkg_resources.evaluate_marker(marker) ) def install_dists(self, dist): """ Extend install_dists to include extras support """ return _itertools.chain( orig.test.install_dists(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 # include unnamed extras or all if self.extras indicated if (not name or self.extras) # never include extras that fail to pass marker eval and self.marker_passes(marker) ) results = list(map(dist.fetch_build_eggs, matching_extras)) return _itertools.chain.from_iterable(results) @staticmethod def _warn_old_setuptools(): msg = ( "pytest-runner will stop working on this version of setuptools; " "please upgrade to setuptools 30.4 or later or pin to " "pytest-runner < 5." ) ver_str = pkg_resources.get_distribution('setuptools').version ver = pkg_resources.parse_version(ver_str) if ver < pkg_resources.parse_version('30.4'): _warnings.warn(msg) def run(self): """ Override run to ensure requirements are available in this session (but don't install them anywhere). """ self._warn_old_setuptools() dist = CustomizedDist() for attr in 'allow_hosts index_url'.split(): setattr(dist, attr, getattr(self, attr)) for attr in ( 'dependency_links install_requires tests_require extras_require ' ).split(): setattr(dist, attr, getattr(self.distribution, attr)) installed_dists = self.install_dists(dist) if self.dry_run: self.announce('skipping tests (dry run)') return paths = map(_operator.attrgetter('location'), installed_dists) with self.paths_on_pythonpath(paths): with self.project_on_sys_path(): return self.run_tests() @property def _argv(self): return ['pytest'] + self.addopts def run_tests(self): """ Invoke pytest, replacing argv. Return result code. """ with _save_argv(_sys.argv[:1] + self.addopts): result_code = __import__('pytest').main() if result_code: raise SystemExit(result_code) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/pyproject.toml0000644252176402575230000000054614533222360020150 0ustar00jaracoprimarygroup[build-system] requires = ["setuptools>=56", "setuptools_scm[toml]>=3.4.1"] build-backend = "setuptools.build_meta" [tool.black] skip-string-normalization = true [tool.setuptools_scm] [pytest.enabler.black] addopts = "--black" [pytest.enabler.mypy] addopts = "--mypy" [pytest.enabler.flake8] addopts = "--flake8" [pytest.enabler.cov] addopts = "--cov" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/pytest.ini0000644252176402575230000000161614533222360017264 0ustar00jaracoprimarygroup[pytest] norecursedirs=dist build .tox .eggs addopts=--doctest-modules doctest_optionflags=ALLOW_UNICODE ELLIPSIS filterwarnings= # Suppress deprecation warning in flake8 ignore:SelectableGroups dict interface is deprecated::flake8 # shopkeep/pytest-black#55 ignore: is not using a cooperative constructor:pytest.PytestDeprecationWarning ignore:The \(fspath. py.path.local\) argument to BlackItem is deprecated.:pytest.PytestDeprecationWarning ignore:BlackItem is an Item subclass and should not be a collector:pytest.PytestWarning # tholo/pytest-flake8#83 ignore: is not using a cooperative constructor:pytest.PytestDeprecationWarning ignore:The \(fspath. py.path.local\) argument to Flake8Item is deprecated.:pytest.PytestDeprecationWarning ignore:Flake8Item is an Item subclass and should not be a collector:pytest.PytestWarning ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1701651796.7914145 pytest-runner-6.0.1/pytest_runner.egg-info/0000755252176402575230000000000014533222525021645 5ustar00jaracoprimarygroup././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651796.0 pytest-runner-6.0.1/pytest_runner.egg-info/PKG-INFO0000644252176402575230000001617614533222524022754 0ustar00jaracoprimarygroupMetadata-Version: 2.1 Name: pytest-runner Version: 6.0.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 Classifier: Development Status :: 7 - Inactive Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Framework :: Pytest Requires-Python: >=3.7 License-File: LICENSE Provides-Extra: testing Requires-Dist: pytest>=6; extra == "testing" Requires-Dist: pytest-checkdocs>=2.4; extra == "testing" Requires-Dist: pytest-flake8; extra == "testing" Requires-Dist: pytest-black>=0.3.7; platform_python_implementation != "PyPy" and extra == "testing" Requires-Dist: pytest-cov; extra == "testing" Requires-Dist: pytest-mypy>=0.9.1; platform_python_implementation != "PyPy" and extra == "testing" Requires-Dist: pytest-enabler>=1.0.1; extra == "testing" Requires-Dist: pytest-virtualenv; extra == "testing" Requires-Dist: types-setuptools; extra == "testing" Provides-Extra: docs Requires-Dist: sphinx; extra == "docs" Requires-Dist: jaraco.packaging>=9; extra == "docs" Requires-Dist: rst.linker>=1.9; extra == "docs" Requires-Dist: jaraco.tidelift>=1.4; extra == "docs" .. image:: https://img.shields.io/pypi/v/pytest-runner.svg :target: `PyPI link`_ .. image:: https://img.shields.io/pypi/pyversions/pytest-runner.svg :target: `PyPI link`_ .. _PyPI link: https://pypi.org/project/pytest-runner .. image:: https://github.com/pytest-dev/pytest-runner/workflows/tests/badge.svg :target: https://github.com/pytest-dev/pytest-runner/actions?query=workflow%3A%22tests%22 :alt: tests .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black :alt: Code style: Black .. .. image:: https://readthedocs.org/projects/skeleton/badge/?version=latest .. :target: https://skeleton.readthedocs.io/en/latest/?badge=latest .. image:: https://img.shields.io/badge/skeleton-2022-informational :target: https://blog.jaraco.com/skeleton .. image:: https://tidelift.com/badges/package/pypi/pytest-runner :target: https://tidelift.com/subscription/pkg/pypi-pytest-runner?utm_source=pypi-pytest-runner&utm_medium=readme Setup scripts can use pytest-runner to add setup.py test support for pytest runner. Deprecation Notice ================== pytest-runner depends on deprecated features of setuptools and relies on features that break security mechanisms in pip. For example 'setup_requires' and 'tests_require' bypass ``pip --require-hashes``. See also `pypa/setuptools#1684 `_. It is recommended that you: - Remove ``'pytest-runner'`` from your ``setup_requires``, preferably removing the ``setup_requires`` option. - Remove ``'pytest'`` and any other testing requirements from ``tests_require``, preferably removing the ``tests_requires`` option. - Select a tool to bootstrap and then run tests such as tox. 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 pip-run `_. 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, ) For Enterprise ============== Available as part of the Tidelift Subscription. This project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use. `Learn more `_. Security Contact ================ To report a security vulnerability, please use the `Tidelift security contact `_. Tidelift will coordinate the fix and disclosure. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651796.0 pytest-runner-6.0.1/pytest_runner.egg-info/SOURCES.txt0000644252176402575230000000102314533222524023524 0ustar00jaracoprimarygroup.coveragerc .editorconfig .flake8 .pre-commit-config.yaml .readthedocs.yml CHANGES.rst LICENSE README.rst mypy.ini pyproject.toml pytest.ini setup.cfg tox.ini .github/FUNDING.yml .github/dependabot.yml .github/workflows/main.yml docs/conf.py docs/history.rst docs/index.rst ptr/__init__.py 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/requires.txt pytest_runner.egg-info/top_level.txt tests/test_ptr.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651796.0 pytest-runner-6.0.1/pytest_runner.egg-info/dependency_links.txt0000644252176402575230000000000114533222524025712 0ustar00jaracoprimarygroup ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651796.0 pytest-runner-6.0.1/pytest_runner.egg-info/entry_points.txt0000644252176402575230000000007214533222524025141 0ustar00jaracoprimarygroup[distutils.commands] ptr = ptr:PyTest pytest = ptr:PyTest ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651796.0 pytest-runner-6.0.1/pytest_runner.egg-info/requires.txt0000644252176402575230000000044014533222524024242 0ustar00jaracoprimarygroup [docs] sphinx jaraco.packaging>=9 rst.linker>=1.9 jaraco.tidelift>=1.4 [testing] pytest>=6 pytest-checkdocs>=2.4 pytest-flake8 pytest-cov pytest-enabler>=1.0.1 pytest-virtualenv types-setuptools [testing:platform_python_implementation != "PyPy"] pytest-black>=0.3.7 pytest-mypy>=0.9.1 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651796.0 pytest-runner-6.0.1/pytest_runner.egg-info/top_level.txt0000644252176402575230000000000414533222524024370 0ustar00jaracoprimarygroupptr ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1701651796.7929323 pytest-runner-6.0.1/setup.cfg0000644252176402575230000000217114533222525017054 0ustar00jaracoprimarygroup[metadata] name = pytest-runner author = Jason R. Coombs author_email = jaraco@jaraco.com description = Invoke py.test as distutils command with dependency resolution long_description = file:README.rst url = https://github.com/pytest-dev/pytest-runner/ classifiers = Development Status :: 7 - Inactive Intended Audience :: Developers License :: OSI Approved :: MIT License Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only Framework :: Pytest [options] packages = find_namespace: include_package_data = true python_requires = >=3.7 install_requires = [options.packages.find] exclude = build* dist* docs* tests* [options.extras_require] testing = pytest >= 6 pytest-checkdocs >= 2.4 pytest-flake8 pytest-black >= 0.3.7; \ python_implementation != "PyPy" pytest-cov pytest-mypy >= 0.9.1; \ python_implementation != "PyPy" pytest-enabler >= 1.0.1 pytest-virtualenv types-setuptools docs = sphinx jaraco.packaging >= 9 rst.linker >= 1.9 jaraco.tidelift >= 1.4 [options.entry_points] distutils.commands = ptr = ptr:PyTest pytest = ptr:PyTest [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1701651796.7910712 pytest-runner-6.0.1/tests/0000755252176402575230000000000014533222525016374 5ustar00jaracoprimarygroup././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701650902.0 pytest-runner-6.0.1/tests/test_ptr.py0000644252176402575230000001215114533220726020613 0ustar00jaracoprimarygroupimport io import os import shutil import sys import tarfile import textwrap import time import itertools import pytest def DALS(s): "dedent and left-strip" return textwrap.dedent(s).lstrip() def make_sdist(dist_path, files): """ Create a simple sdist tarball at dist_path, containing the files listed in ``files`` as ``(filename, content)`` tuples. """ with tarfile.open(dist_path, 'w:gz') as dist: for filename, content in files: file_bytes = io.BytesIO(content.encode('utf-8')) file_info = tarfile.TarInfo(name=filename) file_info.size = len(file_bytes.getvalue()) file_info.mtime = int(time.time()) dist.addfile(file_info, fileobj=file_bytes) @pytest.fixture def venv(virtualenv): yield virtualenv # Workaround virtualenv not cleaning itself as it should... virtualenv.delete = True virtualenv.teardown() setuptools_reqs = ( ['setuptools', 'setuptools==38.4.1'] if sys.version_info < (3, 10) else ['setuptools', 'setuptools==49.0.0'] ) args_variants = ['', '--extras'] @pytest.mark.xfail('platform.system() == "Windows"') @pytest.mark.parametrize( 'setuptools_req, test_args', itertools.product(setuptools_reqs, args_variants) ) def test_egg_fetcher(venv, setuptools_req, test_args): test_args = test_args.split() # Install pytest & pytest-runner. venv.run('pip install pytest .', cwd=os.getcwd()) # Install setuptools version. venv.run('pip install -U'.split() + [setuptools_req]) # For debugging purposes. venv.run('pip freeze --all') # Prepare fake index. index_dir = (venv.workspace / 'index').mkdir() for n in range(5): dist_name = 'barbazquux' + str(n + 1) dist_version = '0.1' dist_sdist = '%s-%s.tar.gz' % (dist_name, dist_version) dist_dir = (index_dir / dist_name).mkdir() make_sdist( dist_dir / dist_sdist, ( ( 'setup.py', textwrap.dedent( ''' from setuptools import setup setup( name={dist_name!r}, version={dist_version!r}, py_modules=[{dist_name!r}], ) ''' ).format(dist_name=dist_name, dist_version=dist_version), ), (dist_name + '.py', ''), ), ) with (dist_dir / 'index.html').open('w') as fp: fp.write( DALS( ''' {dist_sdist}
''' ).format(dist_sdist=dist_sdist) ) # Move barbazquux1 out of the index. shutil.move(index_dir / 'barbazquux1', venv.workspace) barbazquux1_link = ( 'file://' + str(venv.workspace.abspath()) + '/barbazquux1/barbazquux1-0.1.tar.gz' + '#egg=barbazquux1-0.1' ) # Prepare fake project. project_dir = (venv.workspace / 'project-0.1').mkdir() with open(project_dir / 'setup.py', 'w') as fp: fp.write( DALS( ''' from setuptools import setup setup( name='project', version='0.1', dependency_links = [ {barbazquux1_link!r}, ], setup_requires=[ 'pytest-runner', ], install_requires=[ 'barbazquux1', ], tests_require=[ 'pytest', 'barbazquux2', ], extras_require={{ ':"{sys_platform}" in sys_platform': 'barbazquux3', ':"barbazquux" in sys_platform': 'barbazquux4', 'extra': 'barbazquux5', }} ) ''' ).format(sys_platform=sys.platform, barbazquux1_link=barbazquux1_link) ) with open(project_dir / 'setup.cfg', 'w') as fp: fp.write( DALS( ''' [easy_install] index_url = . ''' ) ) with open(project_dir / 'test_stuff.py', 'w') as fp: fp.write( DALS( ''' import pytest def test_stuff(): import barbazquux1 import barbazquux2 import barbazquux3 with pytest.raises(ImportError): import barbazquux4 if {importable_barbazquux5}: import barbazquux5 else: with pytest.raises(ImportError): import barbazquux5 ''' ).format(importable_barbazquux5=('--extras' in test_args)) ) # Run fake project tests. cmd = 'python setup.py pytest'.split() cmd += ['--index-url=' + index_dir.abspath()] cmd += test_args venv.run(cmd, cwd=project_dir) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1701651696.0 pytest-runner-6.0.1/tox.ini0000644252176402575230000000133414533222360016543 0ustar00jaracoprimarygroup[tox] envlist = python minversion = 3.2 # https://github.com/jaraco/skeleton/issues/6 tox_pip_extensions_ext_venv_update = true toxworkdir={env:TOX_WORK_DIR:.tox} [testenv] deps = commands = pytest {posargs} usedevelop = True extras = testing [testenv:docs] extras = docs testing changedir = docs commands = python -m sphinx -W --keep-going . {toxinidir}/build/html [testenv:release] skip_install = True deps = build twine>=3 jaraco.develop>=7.1 passenv = TWINE_PASSWORD GITHUB_TOKEN setenv = TWINE_USERNAME = {env:TWINE_USERNAME:__token__} commands = python -c "import shutil; shutil.rmtree('dist', ignore_errors=True)" python -m build python -m twine upload dist/* python -m jaraco.develop.create-github-release