Metadata-Version: 2.2
Name: pytest-venv
Version: 0.3
Summary: py.test fixture for creating a virtual environment
Home-page: https://github.com/mmerickel/pytest-venv
Author: Michael Merickel
Author-email: michael@merickel.org
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Testing
Description-Content-Type: text/x-rst
License-File: LICENSE.txt
Requires-Dist: packaging
Requires-Dist: pytest
Requires-Dist: virtualenv
Provides-Extra: testing
Requires-Dist: coverage; extra == "testing"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: summary

===========
pytest-venv
===========

.. image:: https://img.shields.io/pypi/v/pytest-venv.svg
    :target: https://pypi.python.org/pypi/pytest-venv

.. image:: https://github.com/mmerickel/pytest-venv/actions/workflows/ci-tests.yml/badge.svg?branch=main
    :target: https://github.com/mmerickel/pytest-venv/actions/workflows/ci-tests.yml?query=branch%3Amain

``pytest-venv`` is a simple pytest plugin that exposes a ``venv`` fixture.
The fixture is used to create a new virtual environment which can be used
to install packages and run commands inside tests.

Usage
=====

.. code-block:: python

    import os

    def test_it(venv):
        venv.install('pyramid', upgrade=True)
        subprocess.check_call(
            [os.path.join(venv.bin, 'pserve'), 'development.ini'],
        )

API
===

The ``venv`` fixture is an instance of
``pytest_venv.VirtualEnvironment(path)`` which exposes the following API:

``path``

  The path to the virtualenv directory.

``bin``

  The path to the bin / Scripts directory.

``python``

  The path to the python executable in the virtualenv.

``create(system_site_packages=False, python=None, *, extra_args=None)``

  Create a virtualenv. This is called automatically by the ``venv`` fixture.
  If ``python`` is ``None`` then the virtual environment will be created
  using the same executable as the active runtime.

``install(pkg_name, editable=False, upgrade=False, *, extra_args=None)``

  Use pip to install a package into the virtualenv. ``pkg_name`` may be a
  path to a package on disk.

``get_version(pkg_name, *, raises=True)``

  Returns a ``packaging.version.Version`` object which is sortable and
  convertable to a string.


0.3 (2023-11-22)
================

- Drop Python 2.7, 3.4, 3.5, 3.6.

- Add support for Python 3.9, 3.10, 3.11, 3.12.

- No longer expect ``pkg_resources`` to be available in the created virtualenv.

- No longer depend on ``setuptools``.

- Add ``extra_args`` to ``install()`` and ``create()`` to pass extra arguments
  to the underlying commands.

- Add ``raises=False`` option to ``get_version()`` to avoid raising an
  exception if a package is not installed.


0.2.1 (2020-08-04)
==================

- Depend directly on ``pytest``.
  See https://github.com/mmerickel/pytest-venv/pull/2

- Add support for Python 3.6, 3.7, and 3.8.
  See https://github.com/mmerickel/pytest-venv/pull/2

0.2 (2016-11-27)
================

- Add ``VirtualEnvironment.get_version`` for querying versions from
  installed packages in the virtual environment.

- Support custom python interpreter paths via
  ``VirtualEnvironment.create(python=...)``.

0.1.1 (2016-11-27)
==================

- Ensure the virtual environment is started with the same Python executable
  as the current process.

0.1 (2016-11-27)
================

- Initial release.
