--- id: pytest-variables version: "3.1.0" license: unclear license_treatment: copyleft maintenance: active --- # pytest-variables — pytest plugin for providing variables to tests/fixtures License: copyleft · Maintenance: active · Downloads: 660.9K/mo ## What it is and what it does pytest-variables is a pytest plugin that externalizes test configuration by loading variables from files into tests as a dictionary. Instead of hardcoding test data or environment values, you specify one or more JSON, YAML, TOML, or Human JSON files via the --variables command-line flag, and the plugin merges them and injects the result into any test that requests the variables fixture. Multiple files are merged in order, with later values overriding earlier ones for non-dictionary keys. The plugin is useful for test suites that need to run against different configurations—different browsers, operating systems, API endpoints, or credentials—without modifying test code. It supports optional formats (YAML, TOML, Human JSON) via extras, allowing you to choose the file format that best suits your team's workflow. It has a single runtime dependency (pytest) and is actively maintained with support for current Python versions. Use it for: - Load browser and OS capabilities for cross-browser Selenium tests from separate JSON files. - Inject API endpoints, credentials, or feature flags into integration tests via YAML configuration. - Parameterize test data (hostnames, ports, timeouts) without modifying test code. - Merge environment-specific variables (dev, staging, prod) from multiple TOML files. - Share test configuration across a team via version-controlled variable files. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pytest plugin that loads test variables from JSON, YAML, TOML, or Human JSON files specified on the command line and makes them available to tests as a dictionary. Yes. It is a stable, actively maintained plugin with low install friction and no security vulnerabilities. The copyleft license is standard for pytest plugins and poses no barrier for most test suites. Install it if your tests need to consume external configuration files or if you want to separate test data from test code. ## Install pip install pytest-variables uv add pytest-variables poetry add pytest-variables ## Installing pytest-variables Before you install: Low friction install with only pytest as a runtime dependency. Actively maintained with recent commits; last release was in 2024 and the repository shows ongoing activity. License in practice: Licensed under Mozilla Public License 2.0 (MPL 2.0), a copyleft license. You must disclose source code modifications and include the license with distributions, but can combine with proprietary code in larger works. Quickstart: pip install pytest-variables # Create variables.json: # {"foo": "bar"} # In test file: def test_example(variables): assert variables['foo'] == 'bar' Requires Python 3.8 or later; optional format support (YAML, TOML, Human JSON) requires installing extras like pytest-variables[yaml]. Verify before relying: - Whether merging behavior for duplicate keys across multiple files is predictable enough for complex test suites. - Performance characteristics when loading very large variable files. ## Package facts - License: not declared (copyleft) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 660.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest variables from file, pytest json configuration, pytest test data injection, pytest yaml fixtures, pytest parameterized test data, test-configuration, pytest-plugin, data-driven-testing [View on SkillFed](https://skillfed.io/packages/pytest-variables) · [View on PyPI](https://pypi.org/project/pytest-variables/)