Skip to main content

Temporary modify your environment variables with context manager

Project description

[![Build Status](](
[![Coverage Status](](

# tempenviron

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

## Usage:
from tempenviron import updated_environ

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


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.

Files for tempenviron, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size tempenviron-0.0.1-py3-none-any.whl (3.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size tempenviron-0.0.1.tar.gz (2.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page