Skip to main content

py.test fixture for creating a virtual environment

Project description

https://img.shields.io/pypi/v/pytest-venv.svg https://img.shields.io/travis/mmerickel/pytest-venv.svg

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

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)

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)

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

get_version(pkg_name)

Returns a pkg_resources.Version object which is sortable and convertable to a string.

0.2.1 (2020-08-04)

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-venv-0.2.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_venv-0.2.1-py2.py3-none-any.whl (4.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-venv-0.2.1.tar.gz.

File metadata

  • Download URL: pytest-venv-0.2.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

File hashes

Hashes for pytest-venv-0.2.1.tar.gz
Algorithm Hash digest
SHA256 169fc8e3555cedfd21cf6208446ad9082ee7a041b60e2d370f1c684fb28d282f
MD5 d340ac63399e78dd1a76fb7f02027252
BLAKE2b-256 6216cdd8ca0ea5023978f7418603d5b4acfb86606c5f5c9bbaf86ab805369bb0

See more details on using hashes here.

File details

Details for the file pytest_venv-0.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_venv-0.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

File hashes

Hashes for pytest_venv-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5c095aeb7ca6e84bb995c895f3c688bd6b0923967fd7252c55207ce1929c7cd1
MD5 d405ec31ce49511d44760ac3736ce471
BLAKE2b-256 f199498c73aeba108831ae2ccf746accc73f01784b675e943e328b60108b04dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page