py.test fixture for creating a virtual environment
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.
import os def test_it(venv): venv.install('pyramid', upgrade=True) subprocess.check_call( [os.path.join(venv.bin, 'pserve'), 'development.ini'], )
The venv fixture is an instance of pytest_venv.VirtualEnvironment(path) which exposes the following API:
The path to the virtualenv directory.
The path to the bin / Scripts directory.
The path to the python executable in the virtualenv.
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.
Returns a pkg_resources.Version object which is sortable and convertable to a string.
- Add VirtualEnvironment.get_version for querying versions from installed packages in the virtual environment.
- Support custom python interpreter paths via VirtualEnvironment.create(python=...).
- Ensure the virtual environment is started with the same Python executable as the current process.
- Initial release.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for pytest_venv-0.2.1-py2.py3-none-any.whl