Name | pytest-env JSON |
Version |
1.1.5
JSON |
| download |
home_page | None |
Summary | pytest plugin that allows you to add environment variables. |
upload_time | 2024-09-17 22:39:18 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT License Copyright (c) 2010-202x The pytest-env developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
env
pytest
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pytest-env
[![PyPI](https://img.shields.io/pypi/v/pytest-env?style=flat-square)](https://pypi.org/project/pytest-env/)
[![Supported Python
versions](https://img.shields.io/pypi/pyversions/pytest-env.svg)](https://pypi.org/project/pytest-env/)
[![check](https://github.com/pytest-dev/pytest-env/actions/workflows/check.yaml/badge.svg)](https://github.com/pytest-dev/pytest-env/actions/workflows/check.yaml)
[![Downloads](https://static.pepy.tech/badge/pytest-env/month)](https://pepy.tech/project/pytest-env)
This is a `pytest` plugin that enables you to set environment variables in a `pytest.ini` or `pyproject.toml` file.
## Installation
Install with pip:
```shell
pip install pytest-env
```
## Usage
### Native form in `pyproject.toml`
```toml
[tool.pytest_env]
HOME = "~/tmp"
RUN_ENV = 1
TRANSFORMED = {value = "{USER}/alpha", transform = true}
SKIP_IF_SET = {value = "on", skip_if_set = true}
```
The `tool.pytest_env` tables keys are the environment variables keys to set. The right hand side of the assignment:
- if an inline table you can set options via the `transform` or `skip_if_set` keys, while the `value` key holds the
value to set (or transform before setting). For transformation the variables you can use is other environment
variable,
- otherwise the value to set for the environment variable to set (casted to a string).
### Via pytest configurations
In your pytest.ini file add a key value pair with `env` as the key and the environment variables as a line separated
list of `KEY=VALUE` entries. The defined variables will be added to the environment before any tests are run:
```ini
[pytest]
env =
HOME=~/tmp
RUN_ENV=test
```
Or with `pyproject.toml`:
```toml
[tool.pytest.ini_options]
env = [
"HOME=~/tmp",
"RUN_ENV=test",
]
```
### Only set if not already set
You can use `D:` (default) as prefix if you don't want to override existing environment variables:
```ini
[pytest]
env =
D:HOME=~/tmp
D:RUN_ENV=test
```
### Transformation
You can use existing environment variables using a python-like format, these environment variables will be expended
before setting the environment variable:
```ini
[pytest]
env =
RUN_PATH=/run/path/{USER}
```
You can apply the `R:` prefix to keep the raw value and skip this transformation step (can combine with the `D:` flag,
order is not important):
```ini
[pytest]
env =
R:RUN_PATH=/run/path/{USER}
R:D:RUN_PATH_IF_NOT_SET=/run/path/{USER}
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-env",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Bern\u00e1t G\u00e1bor <gaborjbernat@gmail.com>",
"keywords": "env, pytest",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/1f/31/27f28431a16b83cab7a636dce59cf397517807d247caa38ee67d65e71ef8/pytest_env-1.1.5.tar.gz",
"platform": null,
"description": "# pytest-env\n\n[![PyPI](https://img.shields.io/pypi/v/pytest-env?style=flat-square)](https://pypi.org/project/pytest-env/)\n[![Supported Python\nversions](https://img.shields.io/pypi/pyversions/pytest-env.svg)](https://pypi.org/project/pytest-env/)\n[![check](https://github.com/pytest-dev/pytest-env/actions/workflows/check.yaml/badge.svg)](https://github.com/pytest-dev/pytest-env/actions/workflows/check.yaml)\n[![Downloads](https://static.pepy.tech/badge/pytest-env/month)](https://pepy.tech/project/pytest-env)\n\nThis is a `pytest` plugin that enables you to set environment variables in a `pytest.ini` or `pyproject.toml` file.\n\n## Installation\n\nInstall with pip:\n\n```shell\npip install pytest-env\n```\n\n## Usage\n\n### Native form in `pyproject.toml`\n\n```toml\n[tool.pytest_env]\nHOME = \"~/tmp\"\nRUN_ENV = 1\nTRANSFORMED = {value = \"{USER}/alpha\", transform = true}\nSKIP_IF_SET = {value = \"on\", skip_if_set = true}\n```\n\nThe `tool.pytest_env` tables keys are the environment variables keys to set. The right hand side of the assignment:\n\n- if an inline table you can set options via the `transform` or `skip_if_set` keys, while the `value` key holds the\n value to set (or transform before setting). For transformation the variables you can use is other environment\n variable,\n- otherwise the value to set for the environment variable to set (casted to a string).\n\n### Via pytest configurations\n\nIn your pytest.ini file add a key value pair with `env` as the key and the environment variables as a line separated\nlist of `KEY=VALUE` entries. The defined variables will be added to the environment before any tests are run:\n\n```ini\n[pytest]\nenv =\n HOME=~/tmp\n RUN_ENV=test\n```\n\nOr with `pyproject.toml`:\n\n```toml\n[tool.pytest.ini_options]\nenv = [\n \"HOME=~/tmp\",\n \"RUN_ENV=test\",\n]\n```\n\n### Only set if not already set\n\nYou can use `D:` (default) as prefix if you don't want to override existing environment variables:\n\n```ini\n[pytest]\nenv =\n D:HOME=~/tmp\n D:RUN_ENV=test\n```\n\n### Transformation\n\nYou can use existing environment variables using a python-like format, these environment variables will be expended\nbefore setting the environment variable:\n\n```ini\n[pytest]\nenv =\n RUN_PATH=/run/path/{USER}\n```\n\nYou can apply the `R:` prefix to keep the raw value and skip this transformation step (can combine with the `D:` flag,\norder is not important):\n\n```ini\n[pytest]\nenv =\n R:RUN_PATH=/run/path/{USER}\n R:D:RUN_PATH_IF_NOT_SET=/run/path/{USER}\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2010-202x The pytest-env developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "pytest plugin that allows you to add environment variables.",
"version": "1.1.5",
"project_urls": {
"Homepage": "https://github.com/pytest-dev/pytest-env",
"Source": "https://github.com/pytest-dev/pytest-env",
"Tracker": "https://github.com/pytest-dev/pytest-env/issues"
},
"split_keywords": [
"env",
" pytest"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "deb887cfb16045c9d4092cfcf526135d73b88101aac83bc1adcf82dfb5fd3833",
"md5": "5b6016b3f911af773af44c233882acdf",
"sha256": "ce90cf8772878515c24b31cd97c7fa1f4481cd68d588419fd45f10ecaee6bc30"
},
"downloads": -1,
"filename": "pytest_env-1.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5b6016b3f911af773af44c233882acdf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6141,
"upload_time": "2024-09-17T22:39:16",
"upload_time_iso_8601": "2024-09-17T22:39:16.942932Z",
"url": "https://files.pythonhosted.org/packages/de/b8/87cfb16045c9d4092cfcf526135d73b88101aac83bc1adcf82dfb5fd3833/pytest_env-1.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1f3127f28431a16b83cab7a636dce59cf397517807d247caa38ee67d65e71ef8",
"md5": "ada293c887a106227d2bbe46aec83b0a",
"sha256": "91209840aa0e43385073ac464a554ad2947cc2fd663a9debf88d03b01e0cc1cf"
},
"downloads": -1,
"filename": "pytest_env-1.1.5.tar.gz",
"has_sig": false,
"md5_digest": "ada293c887a106227d2bbe46aec83b0a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8911,
"upload_time": "2024-09-17T22:39:18",
"upload_time_iso_8601": "2024-09-17T22:39:18.566002Z",
"url": "https://files.pythonhosted.org/packages/1f/31/27f28431a16b83cab7a636dce59cf397517807d247caa38ee67d65e71ef8/pytest_env-1.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-17 22:39:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pytest-dev",
"github_project": "pytest-env",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pytest-env"
}