{"id":13739950,"url":"https://github.com/pytest-dev/pytest-env","last_synced_at":"2025-05-08T19:35:13.268Z","repository":{"id":61888131,"uuid":"549162933","full_name":"pytest-dev/pytest-env","owner":"pytest-dev","description":"pytest plugin to set environment variables in pytest.ini or pyproject.toml file","archived":false,"fork":false,"pushed_at":"2024-10-29T22:40:07.000Z","size":117,"stargazers_count":147,"open_issues_count":2,"forks_count":5,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-10-30T08:03:40.841Z","etag":null,"topics":["plugin","pytest","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pytest-env/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pytest-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"tidelift":"pypi/pytest-env"}},"created_at":"2022-10-10T19:18:13.000Z","updated_at":"2024-10-29T22:40:08.000Z","dependencies_parsed_at":"2023-09-27T03:25:57.864Z","dependency_job_id":"f2e41faa-d134-4c8b-9131-f83cdd4d9543","html_url":"https://github.com/pytest-dev/pytest-env","commit_stats":{"total_commits":89,"total_committers":13,"mean_commits":6.846153846153846,"dds":0.6292134831460674,"last_synced_commit":"7af6ff895881ba9c249dbe82f78be0b4002c37ab"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytest-dev%2Fpytest-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytest-dev%2Fpytest-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytest-dev%2Fpytest-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytest-dev%2Fpytest-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pytest-dev","download_url":"https://codeload.github.com/pytest-dev/pytest-env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224758245,"owners_count":17364973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plugin","pytest","python"],"created_at":"2024-08-03T04:00:40.109Z","updated_at":"2024-11-15T09:30:55.100Z","avatar_url":"https://github.com/pytest-dev.png","language":"Python","readme":"# 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","funding_links":["https://tidelift.com/funding/github/pypi/pytest-env"],"categories":["Testing"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpytest-dev%2Fpytest-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpytest-dev%2Fpytest-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpytest-dev%2Fpytest-env/lists"}