Skip to main content

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

Specifying variables

Use the –variables command line option to specify one or more paths to JSON files containing your variables:

py.test --variables foo.json 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 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

Release files for pytest-variables 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-variables 1.1
File Size Uploaded
pytest-variables-1.1.tar.gz 2.8 kB Details

Release files / pytest-variables-1.1.tar.gz

Download URL pytest-variables-1.1.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
72e79976c4086eef2dbbb04f8841f976e060c5506404c08e384df0689c795f17
BLAKE2b-256 checksum
How to use checksums
66a48f11b0ccfa5c6c5466e24694d28dbb5691daa4ff93164013564e96311e14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.1.0

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4

2 release files

1.3

2 release files

1.2

1 release file

This release

1.1 This release

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page