Name | pytest-variables JSON |
Version |
3.0.0
JSON |
| download |
home_page | |
Summary | pytest plugin for providing variables to tests/fixtures |
upload_time | 2023-05-27 19:26:05 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | |
keywords |
json
pytest
variables
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
pytest-variables
================
pytest-variables is a plugin for pytest_ that provides variables to
tests/fixtures as a dictionary via a file specified on the command line.
.. image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg
:target: https://github.com/pytest-dev/pytest-variables/blob/master/LICENSE
:alt: License
.. image:: https://img.shields.io/pypi/v/pytest-variables.svg
:target: https://pypi.python.org/pypi/pytest-variables/
:alt: PyPI
.. image:: https://img.shields.io/travis/pytest-dev/pytest-variables.svg
:target: https://travis-ci.org/pytest-dev/pytest-variables/
:alt: Travis
.. image:: https://img.shields.io/github/issues-raw/pytest-dev/pytest-variables.svg
:target: https://github.com/pytest-dev/pytest-variables/issues
:alt: Issues
.. image:: https://img.shields.io/requires/github/pytest-dev/pytest-variables.svg
:target: https://requires.io/github/pytest-dev/pytest-variables/requirements/?branch=master
:alt: Requirements
Requirements
------------
You will need the following prerequisites in order to use pytest-variables:
- Python 3.7+ or PyPy3
Installation
------------
To install pytest-variables:
.. code-block:: bash
$ 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:
.. code-block:: bash
$ pip install pytest-variables[hjson]
YAML
~~~~
YAML_ is a human friendly data serialization standard for all programming
languages. To install YAML support:
.. code-block:: bash
$ pip install pytest-variables[yaml]
YAML Loader
^^^^^^^^^^^
You can specify which loader to use by setting ``yaml_loader`` in ``pytest.ini`` (or similar file)
to one of the following:
* BaseLoader
* SafeLoader
* FullLoader (default)
* UnsafeLoader
.. code-block:: ini
[pytest]
yaml_loader = BaseLoader
**Note** that loader is case-sensitive.
To learn more about the loader, see `here <https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation>`_
TOML
~~~~~~~~~~
TOML_ aims to be a minimal configuration file format that's easy to read due to obvious semantics. TOML is designed to map unambiguously to a hash table.
To install TOML support:
.. code-block:: bash
$ pip install pytest-variables[toml]
Contributing
------------
We welcome contributions.
To learn more, see `Development <https://github.com/pytest-dev/pytest-variables/blob/master/development.rst>`_
Specifying variables
--------------------
Use the `--variables` command line option one or more times to specify paths to
files containing your variables:
.. code-block:: bash
$ pytest --variables firefox-53.json --variables windows-10.json
with the following contents for the ``firefox-53.json`` file:
.. code-block:: json
{
"capabilities": {
"browser": "Firefox",
"browser_version": "53.0"
}
}
and another file named ``windows-10.json`` with:
.. code-block:: json
{
"capabilities": {
"os": "Windows",
"os_version": "10",
"resolution": "1280x1024"
}
}
you'll get the merged version of your variables:
.. code-block:: json
{
"capabilities": {
"browser": "Firefox",
"browser_version": "53.0",
"os": "Windows",
"os_version": "10",
"resolution": "1280x1024"
}
}
If multiple files are specified then they will be applied in the order they
appear on the command line. When duplicate keys with non dictionary_ values
are encountered, the last to be applied will take priority.
Accessing variables
-------------------
With a JSON variables file such as:
.. code-block:: json
{
"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_:
.. code-block:: python
def test_foo(self, variables):
assert variables['foo'] == 'bar'
assert variables.get('bar') == 'foo'
assert variables.get('missing') is None
Resources
---------
- `Release Notes`_
- `Issue Tracker`_
- Code_
.. _pytest: http://pytest.org
.. _Human JSON: http://hjson.org
.. _YAML: http://yaml.org
.. _TOML: https://github.com/toml-lang/toml
.. _dictionary: https://docs.python.org/tutorial/datastructures.html#dictionaries
.. _Release Notes: http://github.com/pytest-dev/pytest-variables/blob/master/CHANGES.rst
.. _Issue Tracker: http://github.com/pytest-dev/pytest-variables/issues
.. _Code: http://github.com/pytest-dev/pytest-variables
Raw data
{
"_id": null,
"home_page": "",
"name": "pytest-variables",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "json,pytest,variables",
"author": "",
"author_email": "Dave Hunt <dhunt@mozilla.com>, Jim Brannlund <jimbrannlund@fastmail.com>",
"download_url": "https://files.pythonhosted.org/packages/69/85/ed733ee0ee9ff879512d44a54b2966eae94862c1f5ce1bc2535f74910ef3/pytest_variables-3.0.0.tar.gz",
"platform": null,
"description": "pytest-variables\n================\n\npytest-variables is a plugin for pytest_ that provides variables to\ntests/fixtures as a dictionary via a file specified on the command line.\n\n.. image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg\n :target: https://github.com/pytest-dev/pytest-variables/blob/master/LICENSE\n :alt: License\n.. image:: https://img.shields.io/pypi/v/pytest-variables.svg\n :target: https://pypi.python.org/pypi/pytest-variables/\n :alt: PyPI\n.. image:: https://img.shields.io/travis/pytest-dev/pytest-variables.svg\n :target: https://travis-ci.org/pytest-dev/pytest-variables/\n :alt: Travis\n.. image:: https://img.shields.io/github/issues-raw/pytest-dev/pytest-variables.svg\n :target: https://github.com/pytest-dev/pytest-variables/issues\n :alt: Issues\n.. image:: https://img.shields.io/requires/github/pytest-dev/pytest-variables.svg\n :target: https://requires.io/github/pytest-dev/pytest-variables/requirements/?branch=master\n :alt: Requirements\n\nRequirements\n------------\n\nYou will need the following prerequisites in order to use pytest-variables:\n\n- Python 3.7+ or PyPy3\n\nInstallation\n------------\n\nTo install pytest-variables:\n\n.. code-block:: bash\n\n $ pip install pytest-variables\n\nAdditional formats\n------------------\n\nThe following optional formats are supported, but must be explicitly installed\nas they require additional dependencies:\n\nHuman JSON\n~~~~~~~~~~\n\n`Human JSON`_ is a configuration file format that caters to humans and helps\nreduce the errors they make. To install Human JSON support:\n\n.. code-block:: bash\n\n $ pip install pytest-variables[hjson]\n\nYAML\n~~~~\n\nYAML_ is a human friendly data serialization standard for all programming\nlanguages. To install YAML support:\n\n.. code-block:: bash\n\n $ pip install pytest-variables[yaml]\n\nYAML Loader\n^^^^^^^^^^^\n\nYou can specify which loader to use by setting ``yaml_loader`` in ``pytest.ini`` (or similar file)\nto one of the following:\n\n * BaseLoader\n * SafeLoader\n * FullLoader (default)\n * UnsafeLoader\n\n.. code-block:: ini\n\n [pytest]\n yaml_loader = BaseLoader\n\n**Note** that loader is case-sensitive.\n\nTo learn more about the loader, see `here <https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation>`_\n\nTOML\n~~~~~~~~~~\n\nTOML_ aims to be a minimal configuration file format that's easy to read due to obvious semantics. TOML is designed to map unambiguously to a hash table.\nTo install TOML support:\n\n.. code-block:: bash\n\n $ pip install pytest-variables[toml]\n\nContributing\n------------\n\nWe welcome contributions.\n\nTo learn more, see `Development <https://github.com/pytest-dev/pytest-variables/blob/master/development.rst>`_\n\nSpecifying variables\n--------------------\n\nUse the `--variables` command line option one or more times to specify paths to\nfiles containing your variables:\n\n.. code-block:: bash\n\n $ pytest --variables firefox-53.json --variables windows-10.json\n\n\nwith the following contents for the ``firefox-53.json`` file:\n\n.. code-block:: json\n\n {\n \"capabilities\": {\n \"browser\": \"Firefox\",\n \"browser_version\": \"53.0\"\n }\n }\n\nand another file named ``windows-10.json`` with:\n\n.. code-block:: json\n\n {\n \"capabilities\": {\n \"os\": \"Windows\",\n \"os_version\": \"10\",\n \"resolution\": \"1280x1024\"\n }\n }\n\nyou'll get the merged version of your variables:\n\n.. code-block:: json\n\n {\n \"capabilities\": {\n \"browser\": \"Firefox\",\n \"browser_version\": \"53.0\",\n \"os\": \"Windows\",\n \"os_version\": \"10\",\n \"resolution\": \"1280x1024\"\n }\n }\n\nIf multiple files are specified then they will be applied in the order they\nappear on the command line. When duplicate keys with non dictionary_ values\nare encountered, the last to be applied will take priority.\n\nAccessing variables\n-------------------\n\nWith a JSON variables file such as:\n\n.. code-block:: json\n\n {\n \"foo\": \"bar\",\n \"bar\": \"foo\"\n }\n\nSpecify the `variables` funcarg to make the variables available to your tests.\nThe contents of the files are made available as a dictionary_:\n\n.. code-block:: python\n\n def test_foo(self, variables):\n assert variables['foo'] == 'bar'\n assert variables.get('bar') == 'foo'\n assert variables.get('missing') is None\n\nResources\n---------\n\n- `Release Notes`_\n- `Issue Tracker`_\n- Code_\n\n.. _pytest: http://pytest.org\n.. _Human JSON: http://hjson.org\n.. _YAML: http://yaml.org\n.. _TOML: https://github.com/toml-lang/toml\n.. _dictionary: https://docs.python.org/tutorial/datastructures.html#dictionaries\n.. _Release Notes: http://github.com/pytest-dev/pytest-variables/blob/master/CHANGES.rst\n.. _Issue Tracker: http://github.com/pytest-dev/pytest-variables/issues\n.. _Code: http://github.com/pytest-dev/pytest-variables\n",
"bugtrack_url": null,
"license": "",
"summary": "pytest plugin for providing variables to tests/fixtures",
"version": "3.0.0",
"project_urls": {
"Homepage": "https://github.com/pytest-dev/pytest-variables",
"Source": "https://github.com/pytest-dev/pytest-variables",
"Tracker": "https://github.com/pytest-dev/pytest-variables/issues"
},
"split_keywords": [
"json",
"pytest",
"variables"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "005589d360e448f8ab7db7bf8ace79802c6a231b67c5eefc66e8a53c121d26db",
"md5": "cfefc57797c212b6585d9a7c935f6d15",
"sha256": "190d9d4da5a6013eb02df2049f6047d911cdbe44c5b1734a6acc1748433c93d0"
},
"downloads": -1,
"filename": "pytest_variables-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cfefc57797c212b6585d9a7c935f6d15",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5927,
"upload_time": "2023-05-27T19:26:03",
"upload_time_iso_8601": "2023-05-27T19:26:03.801414Z",
"url": "https://files.pythonhosted.org/packages/00/55/89d360e448f8ab7db7bf8ace79802c6a231b67c5eefc66e8a53c121d26db/pytest_variables-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6985ed733ee0ee9ff879512d44a54b2966eae94862c1f5ce1bc2535f74910ef3",
"md5": "db2ccde2360339508549150706dbc5cb",
"sha256": "ab84235417afac5a0a7dd4c3918287d9c7329d2e16d570d6e943f8d8e02533b9"
},
"downloads": -1,
"filename": "pytest_variables-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "db2ccde2360339508549150706dbc5cb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7284,
"upload_time": "2023-05-27T19:26:05",
"upload_time_iso_8601": "2023-05-27T19:26:05.592316Z",
"url": "https://files.pythonhosted.org/packages/69/85/ed733ee0ee9ff879512d44a54b2966eae94862c1f5ce1bc2535f74910ef3/pytest_variables-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-27 19:26:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pytest-dev",
"github_project": "pytest-variables",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pytest-variables"
}