===========
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/mmerickel/pytest-venv",
"name": "pytest-venv",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Michael Merickel",
"author_email": "michael@merickel.org",
"download_url": "https://files.pythonhosted.org/packages/14/a3/74a456852035c9314d28efcb5bd7e20f7f4fc1070b4791768ed9ae3e889b/pytest-venv-0.3.tar.gz",
"platform": null,
"description": "===========\npytest-venv\n===========\n\n.. image:: https://img.shields.io/pypi/v/pytest-venv.svg\n :target: https://pypi.python.org/pypi/pytest-venv\n\n.. image:: https://github.com/mmerickel/pytest-venv/actions/workflows/ci-tests.yml/badge.svg?branch=main\n :target: https://github.com/mmerickel/pytest-venv/actions/workflows/ci-tests.yml?query=branch%3Amain\n\n``pytest-venv`` is a simple pytest plugin that exposes a ``venv`` fixture.\nThe fixture is used to create a new virtual environment which can be used\nto install packages and run commands inside tests.\n\nUsage\n=====\n\n.. code-block:: python\n\n import os\n\n def test_it(venv):\n venv.install('pyramid', upgrade=True)\n subprocess.check_call(\n [os.path.join(venv.bin, 'pserve'), 'development.ini'],\n )\n\nAPI\n===\n\nThe ``venv`` fixture is an instance of\n``pytest_venv.VirtualEnvironment(path)`` which exposes the following API:\n\n``path``\n\n The path to the virtualenv directory.\n\n``bin``\n\n The path to the bin / Scripts directory.\n\n``python``\n\n The path to the python executable in the virtualenv.\n\n``create(system_site_packages=False, python=None, *, extra_args=None)``\n\n Create a virtualenv. This is called automatically by the ``venv`` fixture.\n If ``python`` is ``None`` then the virtual environment will be created\n using the same executable as the active runtime.\n\n``install(pkg_name, editable=False, upgrade=False, *, extra_args=None)``\n\n Use pip to install a package into the virtualenv. ``pkg_name`` may be a\n path to a package on disk.\n\n``get_version(pkg_name, *, raises=True)``\n\n Returns a ``packaging.version.Version`` object which is sortable and\n convertable to a string.\n\n\n0.3 (2023-11-22)\n================\n\n- Drop Python 2.7, 3.4, 3.5, 3.6.\n\n- Add support for Python 3.9, 3.10, 3.11, 3.12.\n\n- No longer expect ``pkg_resources`` to be available in the created virtualenv.\n\n- No longer depend on ``setuptools``.\n\n- Add ``extra_args`` to ``install()`` and ``create()`` to pass extra arguments\n to the underlying commands.\n\n- Add ``raises=False`` option to ``get_version()`` to avoid raising an\n exception if a package is not installed.\n\n\n0.2.1 (2020-08-04)\n==================\n\n- Depend directly on ``pytest``.\n See https://github.com/mmerickel/pytest-venv/pull/2\n\n- Add support for Python 3.6, 3.7, and 3.8.\n See https://github.com/mmerickel/pytest-venv/pull/2\n\n0.2 (2016-11-27)\n================\n\n- Add ``VirtualEnvironment.get_version`` for querying versions from\n installed packages in the virtual environment.\n\n- Support custom python interpreter paths via\n ``VirtualEnvironment.create(python=...)``.\n\n0.1.1 (2016-11-27)\n==================\n\n- Ensure the virtual environment is started with the same Python executable\n as the current process.\n\n0.1 (2016-11-27)\n================\n\n- Initial release.\n",
"bugtrack_url": null,
"license": "",
"summary": "py.test fixture for creating a virtual environment",
"version": "0.3",
"project_urls": {
"Homepage": "https://github.com/mmerickel/pytest-venv"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d32c681d81b1f339534620ac3cb37c80602613221e8bf8c47c7413c30ad20ab6",
"md5": "3fb88c06c9b6c44f4df585fdea7814e6",
"sha256": "af2961af62107baf85c076cf4cd2ae47a7f345f88cbed9fb04fb51b694b9674e"
},
"downloads": -1,
"filename": "pytest_venv-0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3fb88c06c9b6c44f4df585fdea7814e6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4388,
"upload_time": "2023-11-23T03:52:24",
"upload_time_iso_8601": "2023-11-23T03:52:24.360659Z",
"url": "https://files.pythonhosted.org/packages/d3/2c/681d81b1f339534620ac3cb37c80602613221e8bf8c47c7413c30ad20ab6/pytest_venv-0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "14a374a456852035c9314d28efcb5bd7e20f7f4fc1070b4791768ed9ae3e889b",
"md5": "c1ea20fe02d203f12c023fe2130d4f7d",
"sha256": "b92087bebcb3782984116ca3723c7abdb2ab5e76a75ea9397f4a4c35a544fe18"
},
"downloads": -1,
"filename": "pytest-venv-0.3.tar.gz",
"has_sig": false,
"md5_digest": "c1ea20fe02d203f12c023fe2130d4f7d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8562,
"upload_time": "2023-11-23T03:52:26",
"upload_time_iso_8601": "2023-11-23T03:52:26.078885Z",
"url": "https://files.pythonhosted.org/packages/14/a3/74a456852035c9314d28efcb5bd7e20f7f4fc1070b4791768ed9ae3e889b/pytest-venv-0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-23 03:52:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mmerickel",
"github_project": "pytest-venv",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "pytest-venv"
}