Skip to main content

Temporary modify your environment variables with context manager

Project description

[![Build Status](https://travis-ci.org/u1234x1234/tempenviron.svg?branch=master)](https://travis-ci.org/u1234x1234/tempenviron)
[![Coverage Status](https://coveralls.io/repos/github/u1234x1234/tempenviron/badge.svg?branch=master)](https://coveralls.io/github/u1234x1234/tempenviron?branch=master)

# tempenviron

`tempenviron` allows you to temporary modify your environment variables with context manager.

## Usage:
```python
from tempenviron import updated_environ


# Update with keyword arg
assert 'RANDOM_ENVIRONMENT_VARIABLE' not in os.environ

with updated_environ(RANDOM_ENVIRONMENT_VARIABLE='SOME_VALUE'):
assert os.environ['RANDOM_ENVIRONMENT_VARIABLE'] == 'SOME_VALUE'

assert 'RANDOM_ENVIRONMENT_VARIABLE' not in os.environ


# Or pass a dictionary
with updated_environ({'var1': 'val1', 'var2': 'val2'}):
assert os.environ['var1'] == 'val1'
assert os.environ['var2'] == 'val2'


# Or both. In that case keywords have a higher priority
with updated_environ({'var1': 'val1', 'var2': 'val2'}, var2='val3'):
assert os.environ['var2'] == 'val3'


# To temporary delete an environment variable, set the variable to None
os.environ['var1'] = 'val1'

with updated_environ(var1=None):
assert 'var1' not in os.environ

assert os.environ['var1'] == 'val1'

```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tempenviron-0.0.1.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tempenviron-0.0.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file tempenviron-0.0.1.tar.gz.

File metadata

  • Download URL: tempenviron-0.0.1.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.4

File hashes

Hashes for tempenviron-0.0.1.tar.gz
Algorithm Hash digest
SHA256 74940ef5754fe9f5a9aa5d558fb4cc55bf32d00b321fa88ee6d14760ee38ef91
MD5 d5b68155a602c8a305dfb108f65d224a
BLAKE2b-256 767263e66f5ee0253f4ae0067b7783638ded4f1b1d2ff133cfb139edcbf48951

See more details on using hashes here.

File details

Details for the file tempenviron-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tempenviron-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.4

File hashes

Hashes for tempenviron-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a519962bb796c74dec1a4303941fa84f5e67d6bab57bf7e3817263456aa30bf2
MD5 ddcf5b1e806882490edc76ecb0347c87
BLAKE2b-256 ab7dc1441b89146504c431280219a9cfde6ee95688e235cfdbded1ddf2d970f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page