Run your tests in Bubblewrap sandboxes
Project description
This pytest plugin allows running each test in its own bubblewrap sandbox.
This means each test runs in its own isolated environment, no test has any side-effects on any other.
Basic Usage
Just install the plugin:
$ pip install pytest-bwrap
Then run your tests as usual, with a single added option:
$ py.test --bwrap
Each test will be run in its own sandbox.
Sandbox details
The sandbox will have its own filesystem, layed out as follows:
network access is blocked by default; (see “Options”)
the following are mounted read-only from the host system:
/etc/hosts and /etc/resolv.conf
/usr (and the accompanying /bin, /lib, /sbin, with proper handling of /usr-merge)
the following are mounted from the host system:
/dev
/proc
the current directory (that is, the root of the project you are testing)
the active virtualenv, if running in one
/tmp is a new tmpfs;
Options
Network Access
Tests can optionally be granted network access, by decorating them with pytest_bwrap.decorators.network_enabled().
Additional Read-only Directories
It is sometimes useful to have read-only directories, for example when verifying error handling in the tested functions.
This can be achieved in one of two ways:
decorating the test function with pytest_bwrap.decorators.read_only('/path/to/ro-dir');
setting the extra-ro-dirs option in the pytest configuration;
Example
A full example of how to use this plugin for testing is included.
In particular, it shows how to use the decorators as well as the pytest configuration.
You should be able to switch to that directory, then run the tests:
$ pip install -r requirements.txt $ py.test --bwrap
All the tests should pass.
License
This project is offered under the terms of the GNU Lesser General Public License, either version 3 or any later version, see the COPYING file for details.
0.1
Initial release, with a basic feature-set to run each test in its own sandbox:
host file system is mounted read-only, CWD is mounted read-write;
network access is disabled by default but can be enabled for selected tests;
additional directories can be made read-only;
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pytest-bwrap-0.1.tar.gz
.
File metadata
- Download URL: pytest-bwrap-0.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63726473f0619ebb8d4fd331f14dde6f559be3002b912d78f5ae2d7b4d60f78d |
|
MD5 | ba4763f85b415a710e12e9cfe310c5c1 |
|
BLAKE2b-256 | 8b6adb145307bb4cb453e8c6deb1d007419552d210137d2a94b9dd3eeb9066e4 |