Skip to main content

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 dict via a JSON file specified on the command line.

License PyPI Travis Issues Requirements

Requirements

You will need the following prerequisites in order to use pytest-variables:

  • Python 2.6, 2.7, 3.2, 3.3, 3.4 or PyPy
  • py.test 2.3 or newer

Installation

To install pytest-variables:

pip install pytest-variables

Then run your tests with:

py.test --variables=variables.json

Accessing variables

Create 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 JSON 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


Download files

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

Files for pytest-variables, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size pytest-variables-1.0.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page