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.4 or newer

Installation

To install pytest-variables:

pip install pytest-variables

Specifying variables

Use the –variables command line option one or more times to specify paths to JSON 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 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

Metadata

Release files for pytest-variables 1.2

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.2
File Size Uploaded Provenance Actions
pytest-variables-1.2.tar.gz 2.8 kB Without provenance Details for pytest-variables-1.2.tar.gz

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

Download URL pytest-variables-1.2.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2cdc4b814d7cdb14aff6cde0168bb3ee2fff4f28439f80e679c0c98c27488012
BLAKE2b-256 checksum
How to use checksums
e745a01c6e31c9cc37eb3b81fbf0477562bed81b4558987e254384fc81b5c71e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pytest-variables 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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