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 (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.
Metadata
Release files for pytest-venv 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest-venv-0.2.tar.gz | 6.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_venv-0.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / pytest-venv-0.2.tar.gz
| Download URL | pytest-venv-0.2.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d0f78e0a6b2f6817061fbfbf4fb9c4a289034808946306fc11ee5ad9156e055
|
|
BLAKE2b-256 checksum How to use checksums |
7480364847f0e49fc1617c87ff7d929d2a3f71b0663b73827ccd0c4817f032e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pytest_venv-0.2-py2.py3-none-any.whl
| Download URL | pytest_venv-0.2-py2.py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ec842cbc60affbea6b1136bf9876ca858d0b77f6c58740e69a6e0ef708f43ea3
|
|
BLAKE2b-256 checksum How to use checksums |
13f9acf7cfc40fca6eddd0225382d7bd90de619b8fface0543216b291c2ed98d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |