pollute 1.0.2

Last updated:

0 purchases

pollute 1.0.2 Image
pollute 1.0.2 Images
Add to Cart

Description:

pollute 1.0.2

A decorator and context manager for temporarily modifying os.environ.
# as a context manager
with modified_environ(added={...}, absent=[...]):
...

# as a decorator
@modified_environ(added={...}, absent=[...])
Installation:
$ pip install pollute
modified_environ modifies os.environ in-place, ensuring that all
references to it in the code are updated. All changes made by
modified_environ are reversed when exiting the context or decorator.

Example
import os
from pollute import modified_environ


assert 'HELLO' not in os.environ
assert 'PATH' in os.environ

with modified_environ(added={'HELLO': 'WORLD'}, absent=['PATH']):
assert os.environ['HELLO'] == 'WORLD'
assert 'PATH' not in os.environ

assert 'HELLO' not in os.environ
assert 'PATH' in os.environ

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.