{"categories":[{"label":"Testing","url":"https://skillfed.io/packages/category/software-development-testing/2"}],"enrichment":{"capability":"Detects whether code is running in a test environment (pytest, doctest, or setup.py test) via runtime inspection of sys.argv and execution context.","skillfed_tags":["test-detection","runtime-inspection"],"use_cases":["Conditionally skip expensive initialization or logging in production code when running under pytest.","Detect doctest execution to apply different assertion or output formatting rules.","Shell scripts and CI/CD pipelines that need to branch behavior based on whether tests are active.","Detect setup.py test invocation to apply legacy test runner compatibility logic.","Programmatic test environment checks in application startup code to adjust configuration or mocking."],"what_it_does":"lib-detect-testenv is a runtime detection library that identifies whether your Python code is executing under pytest, doctest (including PyCharm's docrunner), or setup.py test. It works by inspecting sys.argv and execution context to determine the active test runner, allowing you to conditionally enable or disable code paths based on whether tests are running.\n\nThe package exports both a Python API (functions like is_testenv_active(), is_pytest_active(), is_doctest_active()) and a command-line interface for shell scripting and CI/CD integration. It uses a three-level exit code system (0 for detected, 1 for not detected, 2 for error) to support programmatic shell usage. The single runtime dependency is rich-click, and it supports Python 3.10 and later on Linux, macOS, and Windows.","worth_installing":"Yes. Low install friction, permissive license, active maintenance, no known vulnerabilities, and a clear single-purpose API make this a straightforward choice if you need runtime test-environment detection. The CLI and Python API both work well for their intended use cases."},"id":"lib-detect-testenv","links":{"html":"https://skillfed.io/packages/lib-detect-testenv","md":"https://skillfed.io/packages/lib-detect-testenv.md","pypi":"https://pypi.org/project/lib-detect-testenv/"},"maintenance":{"status":"active"},"meta":{"latest_release":"2026-07-31","license_spdx":null,"license_treatment":"permissive","name":"lib-detect-testenv","python_support":"supports_current","summary":"Detect test environment - pytest, doctest, unittest, or regular execution"},"popularity":{"monthly_downloads":2568931,"position":2997,"tier":"top_5000"},"security":{"n_vulnerabilities":0},"version":"3.0.4"}
