MCPcopy
hub / github.com/anthropics/anthropic-sdk-python / update_env

Function update_env

tests/utils.py:154–167  ·  view source on GitHub ↗
(**new_env: str | Omit)

Source from the content-addressed store, hash-verified

152
153@contextlib.contextmanager
154def update_env(**new_env: str | Omit) -> Iterator[None]:
155 old = os.environ.copy()
156
157 try:
158 for name, value in new_env.items():
159 if isinstance(value, Omit):
160 os.environ.pop(name, None)
161 else:
162 os.environ[name] = value
163
164 yield None
165 finally:
166 os.environ.clear()
167 os.environ.update(old)

Callers 4

test_validate_headersMethod · 0.85
test_base_url_envMethod · 0.85
test_validate_headersMethod · 0.85
test_base_url_envMethod · 0.85

Calls 2

copyMethod · 0.45
updateMethod · 0.45

Tested by 4

test_validate_headersMethod · 0.68
test_base_url_envMethod · 0.68
test_validate_headersMethod · 0.68
test_base_url_envMethod · 0.68