{"categories":[{"label":"Utilities","url":"https://skillfed.io/packages/category/utilities/8"},{"label":"Security","url":"https://skillfed.io/packages/category/security/2"},{"label":"Shells","url":"https://skillfed.io/packages/category/system-shells"}],"enrichment":{"capability":"Temporarily override environment variables within a scoped context, automatically restoring the original state when the block exits.","skillfed_tags":["testing","credentials","context-manager"],"use_cases":["Wrap credential injection in tests to ensure secrets are only present during the test and automatically cleaned up afterward","Temporarily override configuration variables for a specific function call without affecting the rest of the application","Suppress or modify environment variables during unit tests to verify behavior under different configurations","Decorate test methods to inject test-specific environment variables without manual setup/teardown","Prevent accidental credential leakage in long-running processes by scoping secrets to the exact code block that uses them"],"what_it_does":"tempenv is a context manager for Python that temporarily sets or unsets environment variables and automatically restores them when the block exits. It's designed for scenarios where credentials or other sensitive configuration must be scoped to a short lifetime\u2014common in testing and in applications that receive secrets via environment variables. The package provides a simple `with TemporaryEnvironment({...})` block that accepts a dictionary of variable names to values; setting a value to `None` unsets the variable. It can optionally warn if code inside the block modifies one of the temporary variables, and can be configured to either restore the original value or leave the modified value in place.\n\nThe package has no runtime dependencies, installs as a pure Python wheel, and supports Python 3.9 through 3.13. It can be used as a context manager in regular code or as a decorator on test methods. The main use case is isolating credential or configuration changes to a specific code scope, ensuring they don't leak into the broader process environment.","worth_installing":"Yes, if you need scoped environment variable management in tests or credential-sensitive code. The package is stable, has no dependencies, and solves a real problem cleanly. The aging maintenance status (509 days since last release) is not a blocker for a simple, focused tool\u2014check whether the code already handles your Python version and use case before adopting."},"id":"tempenv","links":{"html":"https://skillfed.io/packages/tempenv","md":"https://skillfed.io/packages/tempenv.md","pypi":"https://pypi.org/project/tempenv/"},"maintenance":{"status":"aging"},"meta":{"latest_release":"2025-03-23","license_spdx":null,"license_treatment":"permissive","name":"tempenv","python_support":"supports_current","summary":"Environment Variable Context Manager"},"popularity":{"monthly_downloads":181869,"position":10111,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"2.1.0"}
