pytest plugin for providing variables to tests/fixtures
Project description
pytest-variables is a plugin for py.test that provides variables to tests/fixtures as a dictionary via a file specified on the command line.
Requirements
You will need the following prerequisites in order to use pytest-variables:
Python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, or PyPy
py.test 2.6 or newer
Installation
To install pytest-variables:
$ pip install pytest-variables
Additional formats
The following optional formats are supported, but must be explicitly installed as they require additional dependencies:
Human JSON
Human JSON is a configuration file format that caters to humans and helps reduce the errors they make. To install Human JSON support:
$ pip install pytest-variables[hjson]
YAML
YAML is a human friendly data serialization standard for all programming languages. To install YAML support:
$ pip install pytest-variables[yaml]
Specifying variables
Use the –variables command line option one or more times to specify paths to files containing your variables:
$ py.test --variables foo.json --variables bar.json
If multiple files are specified then they will be applied in the order they appear on the command line. When duplicates are encountered, the last to be applied will take priority.
Accessing variables
With a JSON variables file such as:
{
"foo": "bar",
"bar": "foo"
}
Specify the variables funcarg to make the variables available to your tests. The contents of the files are made available as a dictionary:
def test_foo(self, variables):
assert variables['foo'] == 'bar'
assert variables.get('bar') == 'foo'
assert variables.get('missing') is None
Resources
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
Built Distribution
File details
Details for the file pytest-variables-1.3.tar.gz
.
File metadata
- Download URL: pytest-variables-1.3.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9da5f89bdb22bd5f700ecf10787f239190b7832ab3445bf32343cd4e51416825 |
|
MD5 | 1e38ea3d482bb0e9126fa67fe278c8a6 |
|
BLAKE2b-256 | 816147e296e199ae9eec237646143fe4f6696bb4684d232b14ff4115ac51dc74 |
File details
Details for the file pytest_variables-1.3-py2-none-any.whl
.
File metadata
- Download URL: pytest_variables-1.3-py2-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2510568fa4692fe825ba7ebfc6eeb30d29096cd177ba28df28375716f6eadfc9 |
|
MD5 | 429afdde12f7d278af6e03911ac3a580 |
|
BLAKE2b-256 | 537f62e89748bf3932361bd176803a4480ac7747335db732445936e9709edb57 |