Skip to content

Enable the pytest plugin from pytest's own config, not only an env var #339

Description

@vishnuv688

Part of #277

The pytest plugin's only switch is an environment variable. _opted_in() reads
DEVTOOLS_ENABLE/DEVTOOLS_PORT, trace mode reads DEVTOOLS_TRACE, and the
plugin registers no pytest_addoption at all — so there is no way to turn
capture on from the project itself:

DEVTOOLS_ENABLE=1 DEVTOOLS_TRACE=1 pytest        # the only way today

Every pytest plugin offers CLI flags and ini options; an env var is the
fallback for CI, not the interface. It is undiscoverable (pytest --help shows
nothing), uncommittable, and per-shell rather than per-project — a contributor
who clones the repo has no way to see that capture exists.

The opt-in itself is not the problem and must stay. The plugin auto-loads
through an entry point, so installing the package must never change how an
existing suite behaves. A CLI flag or an ini option is equally explicit and
strictly better.

[tool.pytest.ini_options]
devtools = true
devtools_trace = true
pytest --devtools --devtools-trace

Plain scripts already need none of this — devtools.enable(trace=True) is
configured entirely in code, and DEVTOOLS_ENABLE is not consulted for them.
Only the pytest surface is affected.

Worth doing before the first PyPI publish (#294). Changing how capture is
switched on after release is a breaking change for anyone already set up.

Acceptance criteria

pytest --devtools and a [tool.pytest.ini_options] entry each enable capture
with no environment variable, and the same for trace mode. Precedence is CLI →
ini → env. The existing environment variables keep working: CI and the
pnpm demo:python:* scripts use them, and removing them would break setups
that already exist.

Size: S. Blocks #294.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions