$npx skillfedfor your agent

lib-detect-testenv

Detect test environment - pytest, doctest, unittest, or regular execution

Worth itPyPI TestingReleased Jul 20262.6M downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — lib_detect_testenv-3.0.4-py3-none-any.whl
v3.0.4 · released 2026-07-31 · Python >=3.10 · 1 runtime deps: rich-click

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.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.10 or later.
  • Low friction: pure Python wheel with a single runtime dependency (rich-click).
  • Active maintenance with a release 14 days ago.

License · maintenance · safety

MIT (permissive) — MIT license (permissive) — you can use, modify, and distribute this package freely with minimal restrictions.

last release 2026-07-31 (14 days) · last repo commit 2026-08-04

0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,568,931 downloads/mo, #2,997 on PyPI

Verify before relying

pip install lib-detect-testenv

from lib_detect_testenv import is_testenv_active

if is_testenv_active():
    print("Running in test environment")
else:
    print("Running in production")
  • Whether rich-click's CLI integration is required for basic detection functions or optional.
  • Performance characteristics when called repeatedly in tight loops during test execution.
Same gist for agents: .md · .json

What it is and 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.

The 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.

Use it for

  • 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.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

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.

Install

lib-detect-testenv on PyPI

Before you install

Low friction: pure Python wheel with a single runtime dependency (rich-click). Active maintenance with a release 14 days ago. Requires Python 3.10 or later.

Requires Python 3.10 or later.

License in practice

MIT license (permissive) — you can use, modify, and distribute this package freely with minimal restrictions.

Quickstart

pip install lib-detect-testenv

from lib_detect_testenv import is_testenv_active

if is_testenv_active():
    print("Running in test environment")
else:
    print("Running in production")

Verify before relying

  • Whether rich-click's CLI integration is required for basic detection functions or optional.
  • Performance characteristics when called repeatedly in tight loops during test execution.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.10
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
rich-click
MaintenanceActively maintained 14 days since the last release
Last repo commit
First released
Downloads2,568,931 / month, #2,997 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Environment :: ConsoleLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Typing :: Typed

Evidence: lib_detect_testenv-3.0.4-py3-none-any.whl

Tags

Capabilities
detect pytest executiontest environment detectiondoctest runtime checkis code running in testspytest doctest setup.py detectiontest runner identificationconditional test environment logic
Topics
test-detectionruntime-inspection
PyPI keywords
doctestpytesttest-detectiontest-environmenttestingunittest

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “doctest runtime check”

  • lib-detect-testenvDetects whether code is running in a test environment (pytest,…
  • zope.testingProvides testing utilities and frameworks for Python, including…
  • pytest-cythonA pytest plugin that runs doctests embedded in Cython `.pyx`…

Give your agent the search over MCP, or paste the wish link into any chat.

More Testing packages

pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
pytest Worth it
PyPI · Libraries · released Jun 2026

pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.

MITpure Python · 3.10+
1.1Bdownloads / mo
virtualenv Worth it
PyPI · Libraries · released Aug 2026

virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.

MITpure Python · 3.9+
532.9Mdownloads / mo
coverage Worth it
PyPI · Testing · released Aug 2026

Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.

Install it if you want to measure test completeness or enforce coverage thresholds in your project.

permissive licensepure Python · 3.10+
335.8Mdownloads / mo
pytest-asyncio Worth it
PyPI · Testing · released May 2026

pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.

Install it if you write tests for any asyncio-based code.

Apache-2.0pure Python · 3.10+
275.9Mdownloads / mo
pytest-json-ctrf Worth it
PyPI · Testing · released Jul 2026

A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.

Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.

MITpure Python · 3.8+
273.0Mdownloads / mo

See also detect-test-pollution · pytest-markdown-docs · xdoctest · pytest-ignore-test-results · detect_agent · rootpath · pytest-race · deadcode · pytest-doctestplus · pytest-textual-snapshot