All Projects → pytest-dev → pytest-variables

pytest-dev / pytest-variables

Licence: other
Plugin for providing variables to pytest tests/fixtures

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pytest-variables

libcyaml
C library for reading and writing YAML.
Stars: ✭ 165 (+139.13%)
Mutual labels:  yaml
powerflows-dmn
Power Flows DMN - Powerful decisions and rules engine
Stars: ✭ 46 (-33.33%)
Mutual labels:  yaml
idr-metadata
Curated metadata for all studies published in the Image Data Resource
Stars: ✭ 12 (-82.61%)
Mutual labels:  yaml
reinforz
An online quiz app made using react, typescript and material-ui
Stars: ✭ 58 (-15.94%)
Mutual labels:  yaml
webparsy
Node.JS library and cli for scraping websites using Puppeteer (or not) and YAML definitions
Stars: ✭ 40 (-42.03%)
Mutual labels:  yaml
yaml-runtimes
YAML processor runtimes via docker
Stars: ✭ 28 (-59.42%)
Mutual labels:  yaml
yaml.sh
Read YAML files with only Bash
Stars: ✭ 30 (-56.52%)
Mutual labels:  yaml
ADLES
Automated Deployment of Lab Environments System (ADLES)
Stars: ✭ 28 (-59.42%)
Mutual labels:  yaml
yamlpath
Command-line get/set/merge/validate/scan/convert/diff processors for YAML/JSON/Compatible data using powerful, intuitive, command-line friendly syntax.
Stars: ✭ 78 (+13.04%)
Mutual labels:  yaml
write-yaml
Basic node.js utility for converting JSON to YAML and writing formatting YAML files to disk.
Stars: ✭ 38 (-44.93%)
Mutual labels:  yaml
flask for startups
Flask boilerplate using a services oriented structure
Stars: ✭ 210 (+204.35%)
Mutual labels:  pytest
universe-topology
A universal computer knowledge topology for all the programmers worldwide.
Stars: ✭ 47 (-31.88%)
Mutual labels:  pytest
Rocket
Define your release steps 🚀
Stars: ✭ 99 (+43.48%)
Mutual labels:  yaml
Doramon
个人工具汇总:一致性哈希工具,Bitmap工具,布隆过滤器参数生成器,Yaml和properties互转工具,一键式生成整个前后端工具,单机高性能幂等工具,zookeeper客户端工具,分布式全局id生成器,时间转换工具,Http封装工具
Stars: ✭ 53 (-23.19%)
Mutual labels:  yaml
MacroUtils
MacroUtils is a collection of high-level APIs in order to make your life easier when writing STAR-CCM+ JAVA macros.
Stars: ✭ 32 (-53.62%)
Mutual labels:  pytest
wildq
Command-line TOML/JSON/INI/YAML/XML/HCL processor using jq c bindings
Stars: ✭ 22 (-68.12%)
Mutual labels:  yaml
pytest-embedded
A pytest plugin that designed for embedded testing
Stars: ✭ 40 (-42.03%)
Mutual labels:  pytest
nbcelltests
Cell-by-cell testing for production Jupyter notebooks in JupyterLab
Stars: ✭ 66 (-4.35%)
Mutual labels:  pytest
rel
command line tool for managing personal graphs of anything and writing them to dot
Stars: ✭ 51 (-26.09%)
Mutual labels:  yaml
Ubigeo-Peru
Base de datos de departamentos, provincias y distritos del Perú (UBIGEO) actualizada al 2019 (El INEI ha actualizado hasta el 2016). SQL, JSON, XML, CSV, Arreglos PHP, YAML.
Stars: ✭ 113 (+63.77%)
Mutual labels:  yaml

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.

License PyPI Travis Issues Requirements

Requirements

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

  • Python 3.7+ or PyPy3

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]

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
[pytest]
yaml_loader = BaseLoader

Note that loader is case-sensitive.

To learn more about the loader, see here

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:

$ pip install pytest-variables[toml]

Contributing

We welcome contributions.

To learn more, see Development

Specifying variables

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

$ pytest --variables firefox-53.json --variables windows-10.json

with the following contents for the firefox-53.json file:

{
  "capabilities": {
    "browser": "Firefox",
    "browser_version": "53.0"
  }
}

and another file named windows-10.json with:

{
  "capabilities": {
    "os": "Windows",
    "os_version": "10",
    "resolution": "1280x1024"
  }
}

you'll get the merged version of your variables:

{
  "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:

{
  "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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].