{"id":13772010,"url":"https://github.com/wemake-services/pytest-modified-env","last_synced_at":"2025-04-22T17:07:33.536Z","repository":{"id":38151142,"uuid":"453351506","full_name":"wemake-services/pytest-modified-env","owner":"wemake-services","description":"Pytest plugin to fail a test if it leaves modified `os.environ` afterwards.","archived":false,"fork":false,"pushed_at":"2025-03-03T06:07:21.000Z","size":218,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T09:30:52.105Z","etag":null,"topics":["codequality","pytest","pytest-plugin","python3","test","testing","tests","unittest"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pytest-modified-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/wemake-services.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"wemake-services","custom":"https://boosty.to/sobolevn"}},"created_at":"2022-01-29T09:22:52.000Z","updated_at":"2025-03-03T06:07:18.000Z","dependencies_parsed_at":"2024-11-07T01:32:05.369Z","dependency_job_id":"d2a130e3-eb05-4b85-a93a-bf6531ad9831","html_url":"https://github.com/wemake-services/pytest-modified-env","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":0.5,"last_synced_commit":"6372ab3b2695cb653f3434f30bc8a60eaa832ef2"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wemake-services%2Fpytest-modified-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wemake-services%2Fpytest-modified-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wemake-services%2Fpytest-modified-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wemake-services%2Fpytest-modified-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wemake-services","download_url":"https://codeload.github.com/wemake-services/pytest-modified-env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249268438,"owners_count":21240927,"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":["codequality","pytest","pytest-plugin","python3","test","testing","tests","unittest"],"created_at":"2024-08-03T17:00:58.752Z","updated_at":"2025-04-16T21:31:55.705Z","avatar_url":"https://github.com/wemake-services.png","language":"Python","funding_links":["https://github.com/sponsors/wemake-services","https://boosty.to/sobolevn"],"categories":["Plugins","Python"],"sub_categories":[],"readme":"# pytest-modified-env\n\n[![wemake.services](https://img.shields.io/badge/%20-wemake.services-green.svg?label=%20\u0026logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC%2FxhBQAAAAFzUkdCAK7OHOkAAAAbUExURQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP%2F%2F%2F5TvxDIAAAAIdFJOUwAjRA8xXANAL%2Bv0SAAAADNJREFUGNNjYCAIOJjRBdBFWMkVQeGzcHAwksJnAPPZGOGAASzPzAEHEGVsLExQwE7YswCb7AFZSF3bbAAAAABJRU5ErkJggg%3D%3D)](https://wemake.services)\n[![test](https://github.com/wemake-services/pytest-modified-env/actions/workflows/test.yml/badge.svg?branch=master\u0026event=push)](https://github.com/wemake-services/pytest-modified-env/actions/workflows/test.yml)\n[![Python Version](https://img.shields.io/pypi/pyversions/pytest-modified-env.svg)](https://pypi.org/project/pytest-modified-env/)\n[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)\n\nPytest plugin to fail a test if it leaves modified `os.environ` afterwards.\n\nExample:\n\n```python\nimport os\n\ndef test_that_modifies_env() -\u003e None:\n    os.environ['CUSTOM_ENV'] = '1'\n```\n\nWith `pytest-modified-env` plugin installed, this test will fail:\n\n```\n___________________________ test_that_modifies_env ____________________________\ntest_that_modifies_env:4: in pytest_runtest_call\nE   RuntimeError: os.environ was changed\n```\n\nBecause it adds `CUSTOM_ENV` inside a test and does not clean it up.\nIn theory it can affect other tests and tests should be isolated!\n\n\n## Installation\n\n```bash\npip install pytest-modified-env\n```\n\n\n## Extras\n\nIn some cases test still might modify the env in this way. \nBut, it needs an explicit approval for that:\n\n```python\nimport os\nimport pytest\n\n@pytest.mark.modify_env()\ndef test_that_modifies_env() -\u003e None:\n    os.environ['CUSTOM_ENV'] = '1'\n```\n\nThis test won't fail, eventhough it adds `CUSTOM_ENV`,\nbecause it has `modifies_env` marker.\n\n\n## License\n\n[MIT](https://github.com/wemake-services/pytest-modified-env/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwemake-services%2Fpytest-modified-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwemake-services%2Fpytest-modified-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwemake-services%2Fpytest-modified-env/lists"}